Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF - How to make PDF with 0 margins? Options
Tomas
Posted: Thursday, February 12, 2015 7:26:59 AM
Rank: Newbie
Groups: Member

Joined: 2/12/2015
Posts: 1
Hi,

I'm trying the trial version of EO.PDF before buying it and I can't figure out how to set one page layout to be fixed in 900px width and 1273px height, as well as with 0 margins (A4 page size, just in smaller resolution);

The options I use:

HtmlToPdf.Options.PageSize = new Size(900, 1273);
HtmlToPdf.Options.OutputArea = new Rectangle(0, 0, 900, 1273);
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.AutoAdjustForDPI = false;

And my CSS:

.container {
widht: 900px;
height: 1273px;
}

But options don't produce the results I'm after - generated PDF has non-zero margins set anyway. Maby it's because of the trial version?

How to set options / css to make generated pdf to be 900px width, 1273px height and 0 margins?

Thank you for your help!
eo_support
Posted: Friday, February 13, 2015 9:54:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

Your code is correct except that the size is in inches, not in pixels. The final pixel size is determined by a "zoom level". The formula to convert inch to pixel is as follow:

pixel_size = inch_size * screen_dpi / zoom_level

For example, if the inch width is 6.5 inches (8.5 inches excluding 1 inch margin on each side), screen_dpi is 96 and zoom_level is 0.5, then the pixel width would be 6.5 * 96 / 0.5 = 1248 pixels. In your case:

1. When you set AutoAdjustForDPI to false, screen_dpi will always be 96 (otherwise it takes whatever DPI setting of your Windows default screen);
2. When you set AutoFitX/AutoFitY to None, zoom_level is always 1;

So in order to get the inch value you want to pass to PageSize/AutputArea, all you need to do is to divide your pixel value by 96.

Hope this helps. Please feel free to let us know if you still have any more questions.

Thanks!


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.