You are not logged in.
Pages: 1
Hi All,
I've come across this library and it is doing everything I'm asking of it so far. I've hit a small snag though. This metafile http://www.lmp.co.uk/files/schedule.emf is causing me some headaches. I create a small test program for this metafile and I'm confused with the output.
const
OutputFileName = 'schedule.pdf';
InputFileName = 'schedule.emf';
var
PdfDoc : TPDFDocumentGDI;
PdfPage : TPdfpage;
Emf : TMetafile;
begin
Emf := TMetafile.Create();
Emf.LoadFromFile(InputFileName);
PdfDoc := TPdfDocumentGDI.Create;
PdfDoc.CompressionMethod := cmFlateDecode;
PdfDoc.DefaultPaperSize := psA4;
PdfDoc.DefaultPageLandscape := True;
PdfPage := PdfDoc.AddPage();
//PdfDoc.VCLCanvas.Draw(0, 0, Emf); // This gives black and white output only
//PdfDoc.Canvas.RenderMetaFile(Emf, 1); // This gives a blank PDF
PdfDoc.SaveToFile(OutputFileName);
PdfDoc.Free();
FreeAndNil(Emf);
end.
When run with PdfDoc.VCLCanvas.Draw uncommented I get a black and white output. Some lines are also missing. When PdfDoc.Canvas.RenderMetaFile is uncommented I get a blank PDF. Am I missing something obvious?
Looking though the forum somebody recommended looking at EMFExplorer to see if the meta file had some odd coding in it. I've done this and as long as I switch off GDI+ rendering then is shows OK. Look through the EMF data it appears all calls are supported in the PDF engine except EMR_SETROP2. I'm just trying to work out what this does and implement it if necessary .... although this isn't my area of expertise and might take some time
Many thanks for any help.
Ryan
Offline
Apologies for that it looks like our server won't accept EMF files. I've zipped it up and it can be downloaded from:
Offline
Hi All,
Just following up on my post from yesterday. I've been able to render the metafile to PDF using the following code:
const
OutputFileName = 'schedule.pdf';
InputFileName = 'schedule.emf';
var
PdfDoc : TPDFDocumentGDI;
PdfPage : TPdfpage;
Emf : TMetafile;
R : TRect;
begin
Emf := TMetafile.Create();
Emf.LoadFromFile(InputFileName);
Gdip := TGDIPlusFull.Create;
PdfDoc := TPdfDocumentGDI.Create;
PdfDoc.CompressionMethod := cmFlateDecode;
PdfDoc.DefaultPaperSize := psA4;
PdfDoc.DefaultPageLandscape := True;
PdfPage := PdfDoc.AddPage();
R.Left := 0;
R.Top := 0;
R.Bottom := Emf.Height;
R.Width := Emf.Width;
Gdip.DrawAntiAliased(Emf, PdfDoc.VCLCanvas.Handle, R, smAntiAlias, trhClearTypeGridFit);
PdfDoc.SaveToFile(OutputFileName);
PdfDoc.Free();
FreeAndNil(Emf);
end.
This produces a complete colour copy of the PDF document. The metafile has come from the DevExpress printing system. I'll post some code in another thread showing how to get the output from this into your PDF document.
Take care,
Ryan
Offline
Pages: 1