#1 2013-09-03 13:59:34

martin.roller
Member
Registered: 2013-09-03
Posts: 1

Included EMF image gets wrong

Hello,

I used synopse for creating pdf from QuickReport metafile with included EMF image by following code:

oPdf := TPdfDocumentGDI.Create;
...
aMeta := QRPrinter.PageList.GetPage(i);
oPdf.AddPage;
oPdf.VCLCanvas.Draw(0, 0, aMeta);
...
oPdf.SaveToFile(PdfSoubor);
oPdf.free;

There is a problem that the included EMF image gets wrong in the final pdf file.

Source EMF file: http://www.hjsoft.cz/temp/Tisk1.emf
Result PDF file: http://www.hjsoft.cz/temp/Tisk1.pdf

Do you have any idea what is wrong?

Thanks.

Best Regards.

Martin Roller

Last edited by martin.roller (2013-09-03 14:00:05)

Offline

#2 2013-09-03 14:54:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Included EMF image gets wrong

If you use tpExactTextCharacterPositining option, it will render as expected.

procedure ConvertImage2Pdf(gr: TGraphic; const FileName: String);
var
  PDF: TPDFDocument;
  AMeta: TMetafile;
begin
  PDF := TPdfDocument.Create;
  try
    AMeta := gr as TMetafile;
    Pdf.AddPage;
    Pdf.Canvas.RenderMetaFile(aMeta, 1, 0, 0, tpExactTextCharacterPositining);
    Pdf.SaveToFile(FileName);
  finally
    Pdf.free;
  end;
  ShellExecute(Application.MainForm.Handle,'open',Pointer(FileName),
    nil,nil,SW_NORMAL);
end;

Offline

Board footer

Powered by FluxBB