Welcome Guest Search | Active Topics | Sign In | Register

Extra margins Options
Toni
Posted: Friday, November 30, 2018 6:09:30 AM
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
eo_support
Posted: Friday, November 30, 2018 9:36:02 AM
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.aspx

Thanks!
Toni
Posted: Monday, December 3, 2018 8:42:48 AM
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);
eo_support
Posted: Tuesday, December 4, 2018 5:14:51 AM
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.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.