You are not logged in.
Pages: 1
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.
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.
Sorry for bother you, I already solve the problem.
My calculation was incorrect. The code bellow it's correct for me.
xWidth := xRepClass.PageCtrl.FMeta.Width;
xHeight := xRepClass.PageCtrl.FMeta.Height;
xLeft := Round(FCfgPage.Left * PixelsCentimeters);
xTop := Round(FCfgPage.Top * PixelsCentimeters);
xRight := Round(FCfgPage.Right * PixelsCentimeters);
xBottom := Round(FCfgPage.Bottom * PixelsCentimeters);
xLeft := MulDiv(xLeft, 72, Screen.PixelsPerInch);
xTop := MulDiv(xTop, 72, Screen.PixelsPerInch);
xRight := MulDiv(xRight, 72, Screen.PixelsPerInch);
xBottom := MulDiv(xBottom, 72, Screen.PixelsPerInch);
xWidth := MulDiv(xWidth, 72, xPDF.ScreenLogPixels);
xHeight := MulDiv(xHeight, 72, xPDF.ScreenLogPixels);
xWidth := xWidth + xLeft + xRight;
xHeight := xHeight + xTop + xBottom;
xPDF.DefaultPageWidth := xWidth;
xPDF.DefaultPageHeight := xHeight;
xPDF.AddPage;
xPDF.Canvas.RenderMetaFile(xRepClass.PageCtrl.FMeta, 1.0, xLeft, xTop);
Hello friends.
My metafile doesn't has margins, but I would like to make a PDF with margins (left and top).
Now the PDF always stay in Left = Top = 0
I would like that my PDF had Left=0.5 cm and Top = 0.5 cm.
I tried without success. I already found post but nothing that help to solve my problem.
Thanks any help.
Thanks, the fix solved the problem, now passed at the validator.
Hi,
I have the same problem but with a metafile:
xPDF.AddPage;
xPDF.Canvas.RenderMetaFile(MyMeta);
I try to validate the generated PDF/A file at http://www.pdf-tools.com/pdf/validate-pdfa-online.aspx
But the validator also shows the same problem that you mentioned.
Kind regards,
Márcio Koch
Pages: 1