Rank: Newbie Groups: Member
Joined: 11/30/2018 Posts: 2
|
Hi,
We just purchased Essential Objects for converting HTML pages to PDFs since another tool (wkhtmltopdf) that we were using had troubles with content security policies. Everything seems to be working ok, apart from margins: for some reason the tool adds extra margins around the PDF. I've tried forcing the margins to zero or even negative
HtmlToPdf.Options.OutputArea = new RectangleF(0f, 0f, 0f, 0f); HtmlToPdf.Options.OutputArea = new RectangleF(-10f, -10f, -10f, -10f);
I've also tried zooming, but with no effect. The code is very simple:
HtmlToPdf.Options.UsePrintMedia = true; HtmlToPdf.Options.PageSize = PdfPageSizes.A4; using (var stream = new MemoryStream()) { HtmlToPdf.ConvertUrl(ssURL, stream); ssPDFBinary = stream.ToArray(); }
How can I remove the extra margins? With wkhtmltopdf there is no extra margins.
Br, Toni
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, Your code looks fine. Can you send us a test HTML file so that we can take a look? There might be extra margin/paddings in your HTML file. See here for more information on how to send test files to us: https://www.essentialobjects.com/forum/test_project.aspxThanks!
|
Rank: Newbie Groups: Member
Joined: 11/30/2018 Posts: 2
|
I was able to fix this by setting the OutputArea like this:
HtmlToPdf.Options.OutputArea = new RectangleF(0f, 0f, PdfPageSizes.A4.Width, PdfPageSizes.A4.Height);
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Yes. That's the correct way to set it. Sorry that we didn't spot the problem earlier.
Please feel free to let us know if you run into anything else.
|