mORMot
mORMot copied to clipboard
Fix fill region bugs in SynPDF
These changes fix some bugs in SynPDF relating to filling regions.
- The first commit ensures complex regions are filled using the defined region rather than the bounding rectangle
- The second commit fixes a bug where the current brush is incorrectly changed when filling a region
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