You are not logged in.
Pages: 1
The code below should produce a PDF file in A4 size with an ellipse inside touching the borders of A4 sheet.But it does not. A scale of 1.333 is needed instead of 1.0 to reach that.
procedure SaveAsPdf;
var
MetaFile: TMetafile;
MetaFileCanvas: TMetafileCanvas;
Pdf: TPdfDocument; //TPdfDocumentGDI ???
begin
Pdf := TPdfDocument.Create;
try
//psA4, psA5, psA3, psLetter, psLegal, psUserDefined
Pdf.DefaultPaperSize := psA4;
Log('DefaultPageWidth: %d', [Pdf.DefaultPageWidth]);
Log('DefaultPageHeight: %d', [Pdf.DefaultPageHeight]);
// 595 = 210 mm * 72 dpi
// 842 = 297 mm * 72 dpi
Metafile := TMetafile.Create;
MetaFileCanvas := TMetaFileCanvas.Create(Metafile, 0);
try
MetaFileCanvas.Ellipse(Rect(0, 0, 594, 841));
finally
MetaFileCanvas.Free;
end;
Pdf.NewDoc;
Pdf.AddPage;
Pdf.Canvas.RenderMetaFile(Metafile, 1.3333333, 0, 0);
Pdf.SaveToFile('c:\test1.pdf');
finally
Pdf.Free;
end;
end;
Last edited by RalfS (2014-10-07 20:21:16)
Offline
You are confusing pdf size units and metafile pixel scale, which follows the registered DPI.
Both values do have a diverse context so do not have the same DPI, by design. For instance, pdf coordinates are floats whereas they are integers in metafile.
Offline
You mean pdf has 72 dpi and metafile 100dpmm=2540dpi?
Offline
Yes, it would depend on your settings for metafile, and will be fixed for pdf.
See http://blogs.datalogics.com/2012/09/13/ … e-systems/
and https://www.leadtools.com/help/leadtool … ystem.html
Offline
Thank you for pointing that out!
Offline
Pages: 1