You are not logged in.
I need to render a metafile with the same size that the page, but with margins (the metafile is without margins). The bounds of the metafile needs to be reduced to can fit it with margins in the page (something like TCanvas.StreachDraw)
I tried to use the RenderMetaFile routine but without success. I changed the R.Right and R.Bottom but don't worked.
Anybody has some sugestion about how to solve this?
Kind regards,
Márcio.
Offline
This library is awesome, I replaced the TPdfDocument by TPdfDocumentGDI and I used code like bellow:
//...
xPDFGDI := TPdfDocumentGDI.Create(False, 0, True, nil); //With PDF/A
try
xPDFGDI.ScreenLogPixels := 72;
for i := 0 to PagesCount - 1 do
begin
//Get the width and height with resolution 72 dpi.
xWidth := MulDiv(Round(xPageWidth), 72, Screen.PixelsPerInch);
xHeight := MulDiv(Round(xPageHeight), 72, Screen.PixelsPerInch);
//The width and height properties must be set before to call AddPage.
xPDFGDI.DefaultPageWidth := xWidth;
xPDFGDI.DefaultPageHeight := xHeight;
//Adjust the resolution from 96 dpi to 72 dpi
xLeft := MulDiv(xLeft, 72, Screen.PixelsPerInch);
xTop := MulDiv(xTop, 72, Screen.PixelsPerInch);
xRight := MulDiv(xRight, 72, Screen.PixelsPerInch);
xBottom := MulDiv(xBottom, 72, Screen.PixelsPerInch);
//Calculates de printable area
xWidth := xWidth - (xLeft + xRight);
xHeight := xHeight - (xTop + xBottom);
//Calculate the final coordinates
xRight := xLeft + xWidth;
xBottom := xTop + xHeight;
//Add a new page to PDF
xPDFGDI.AddPage;
//Render the metafile on PDF canvas with StretchDraw.
xPDFGDI.VCLCanvas.StretchDraw(Rect(xLeft, xTop, xRight, xBottom), Pages[i].Meta);
end;
//Saves the PDF/A file in the disk.
xPDFGDI.SaveToFile(aFileName);
finally
xPDFGDI.Free;
end;
Worked perfectly, now I can change de margins as I need and the metafile is drawn correct into the remaining drawing area.
Kind regards,
Márcio Koch.
Offline
hi, here i found a problem, when embed font , call TPdfFontTrueType.PrepareForSaving frequently , it appears out of memory; use vmmap tools find that virtual Memory leaks(private data). can any one help me, thanks!
Offline