#1 2014-07-14 14:26:51

lobokoch
Member
Registered: 2014-07-11
Posts: 6

Set left end top margins to PDF

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.

Offline

#2 2014-07-14 15:00:33

lobokoch
Member
Registered: 2014-07-11
Posts: 6

Re: Set left end top margins to PDF

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);

Offline

#3 2014-07-14 15:31:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: Set left end top margins to PDF

Thanks for sharing.

I just did "stick" the topic so that it will appear at the top of the forum.
It may be convenient for other users.

Offline

Board footer

Powered by FluxBB