Open iadcode opened 2 years ago
These changes fix some bugs in SynPDF:
Before the changes After the changes
This behaviour can be tested with code such as
procedure EmfToPdf(EmfFilename: String; PdfFilename: String); const C_PDFPPI = 72; C_MMperInch = 25.4; var PDFDocument: TPdfDocument; Metafile: TMetafile; Scale: Single; begin Metafile := TMetafile.Create; try Metafile.LoadFromFile(EmfFilename); PDFDocument := TPdfDocument.Create(False, 0, False); try PDFDocument.DefaultPaperSize := psA4; PDFDocument.ScreenLogPixels := C_PDFPPI; PDFDocument.AddPage; Scale := C_PDFPPI / Trunc((Metafile.Width * 100) / (Metafile.MMWidth / C_MMperInch)); PDFDocument.Canvas.RenderMetaFile(Metafile, Scale, Scale, 0, 0, tpSetTextJustification, 99, 101, tcAlwaysClip); PDFDocument.SaveToFile(PdfFilename); finally FreeAndNil(PDFDocument); end; finally FreeAndNil(Metafile); end; end;
And using an EMF such as the one in this zip: BugsEMF.zip
These changes fix some bugs in SynPDF:
Before the changes
After the changes
![image](https://user-images.githubusercontent.com/18545429/147025502-f3e3bb53-1cd9-45ea-a216-c90181ee4d23.png)
This behaviour can be tested with code such as
And using an EMF such as the one in this zip: BugsEMF.zip