You are not logged in.
Pages: 1
Hi.
I need to render a Metafile using canvas.RenderMetafile at position x:0, y:0.
After do this, a got Margins at the resulting pdf.
How can I force the PDF to have NO MARGINS ?
Offline
How are you creating your renderning?
If you use SQlite3Pages, you'll have margins by default.
But if you use directly the TSynPdf class, you won't have any margin.
1. What is your code?
2. Are you sure you do not set any margin when printing the pdf (Acrobat Reader may add margins at printing)?
Online
This is my code:
with TPdfDocumentGDI.Create do
try
UseUniscribe := True;
CompressionMethod := cmFlateDecode;
ScreenLogPixels := 72;
NewDoc;
page := TMetafile.Create;
try
for i := 1 to GraphicReport.PageCount do
begin
GraphicReport.DrawPage(i, page); // this this the METAFILE generated by my ReportGenerator
with AddPage do
begin
PageWidth := Max(PageWidth, page.Width + (MARGIN * 2));
PageHeight := Max(PageHeight, page.Height + (MARGIN * 2));
Canvas.RenderMetaFile(page, 1, 0, 0, False);
end;
end;
finally
page.Free;
end;
SaveToStream(Stream);
finally
Free;
end;
After the export, the PDF has rendered my metafile out of the pdf page. the OffsetY seems not being respected.
More curious still is the following ...
The more I increase the offsetY (200, 300, 400 ...) the top margin decreases instead of increasing.
Offline
Are you using the latest version from the source code repository?
You are mixing points and mm when setting PageWidth/PageHeight.
Note also that PDF coordinates are not working the same as GDI coordinates: they are bottom-left based.
What about leaving the page size by default?
Online
I solved the problem.
I noticed the following:
Change the page size causes the problem. I had to use the DefaultPageWidth and DefaultPageHeight.
And thanks about the tip:
"Note also that PDF coordinates are not working the same as GDI coordinates: they are bottom-left based."
Please, make tests changing the page size to smaller and bigger pages.
I think there is any problem related to changing the page size.
Try to make a PDF, add a new page and decrease the size of this page. Then try to paint a metafile of the same size on this page.
Thanks.
Offline
But if you use directly the TSynPdf class, you won't have any margin.
Sorry, the class TSynPdf does not exist.
Offline
Pages: 1