#1 2013-06-20 14:13:04

yiyun18
Member
Registered: 2013-06-20
Posts: 3

some emf image can't convert to pdf file

Hello,
   I need to create a pdf file from the emf image. The code below can work well to some emf images, but other emf images can't work. The emf file can be download from http://url.cn/FBFSBe .

thanks

procedure TForm1.Button2Click(Sender: TObject);
const
  OutputFileName = 'c:\1.pdf';
  InputFileName = 'C:\tmpemf\3.emf';
var
  PdfDoc   : TPDFDocumentGDI;
  Emf       : TMetafile;
  R          : TRect;
  Gdip    : TGDIPlusFull;
begin
  Emf := TMetafile.Create();
  Emf.LoadFromFile(InputFileName);
  
  Gdip := TGDIPlusFull.Create;

  PdfDoc := TPdfDocumentGDI.Create;
  PdfDoc.CompressionMethod := cmFlateDecode;
  PdfDoc.DefaultPaperSize := psA4;
  PdfDoc.AddPage;

  R.Left := 0;
  R.Top := 0;
  R.Bottom := Emf.Height;
  R.Right := Emf.Width;
  Gdip.DrawAntiAliased(Emf, PdfDoc.VCLCanvas.Handle, R, smAntiAlias, trhClearTypeGridFit);

  PdfDoc.SaveToFile(OutputFileName);
  PdfDoc.Free();

  FreeAndNil(Emf);
  end;

Offline

#2 2013-06-25 11:47:48

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

Re: some emf image can't convert to pdf file

AFAIK pdf generation just work as expected (tested with latest "unstable" version from our source code repository).

There was an issue with GDI+ rendering.
Should be fixed now by http://synopse.info/fossil/info/88816ae3ce

Thanks for the feedback.

Offline

Board footer

Powered by FluxBB