|
Rank: Newbie Groups: Member
Joined: 11/3/2016 Posts: 4
|
I am trying to generate Image that looks and has dimensions exactly like PDF file thats being generated. One of the requirements is that I am able to "Zoom" into the image making all fonts bigger. This works beautifully using ZoomLevel option for PDF, but no matter what the value fo that option is, the image is always returned without any zoom.
Options that are set: HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoAdjustForDPI = false;
HtmlToPdf.Options.ZoomLevel = 2;
Is it possible to use ZoomLevel with GeneratePageImages together such that if ZoomLevel is greater than 1, the content would be zoomed in? (ie. larger fonts, similar to how it currently works for PDF).
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please set HtmlToPdf.Options.AutoFitX and AutoFitY to None. The page images generated with GeneratePageImages flag should always match the final PDF file. However ZoomLevel value greater than 1 will be ignored with the default AutoFitX/AutoFitY value since the default value only shrink the page (because by default a PDF page is almost always narrower than a typical browser window/web page), thus when the default value are used, only ZoomLevel less than 1 will have any effect.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/3/2016 Posts: 4
|
Hello,
I did set both of those options to None as shown in my previous post.
If i set the following options: HtmlToPdf.Options.ZoomLevel = 2f; HtmlToPdf.Options.PageSize = new SizeF(ToInches(500), ToInches(300)); HtmlToPdf.Options.OutputArea = new RectangleF(0, 0, ToInches(500), ToInches(300));
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoAdjustForDPI = false;
I get back 250x150 image that has 1:1 font sizing with original
If i try to render that as PDF, I get back document that is 5.21 x 3.13 inches * 96dpi ~ 500x300.
What I am looking to do is to get back image that is 500x300 but where all of the content is "zoomed" in by a factor of 2.
ToInches function is: public float ToInches(float pixels) { return pixels/ BASE_DPI ; }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
This is just to let you know that we have confirmed this to be an issue with the 2016 builds. We have posted build 2017.0.31 and the new build should resolve this issue.
Please keep in mind that depending on the value of your BASE_DPI, the pixel size of the image may not be 500 by 300 in your case. The basic unit in a PDF file is a "point", which is 1/72 inch, where as the basic unit on screen is a "dot", which usually is 1/96 inch. If your 500 by 300 are "points", then the following calculation applies (for demonstration purpose we calculate width only):
1. 500 points = 500 / 72 inches = 6.94 inch This produces the final PDF file to be 6.96 inch wide
2. 6.94 inch = 6.94 * 96 = 666 pixels This produces the image file to be 666 pixels wide
Here 666 pixels and 500 points will represents the same width if printed out on paper. However the differ in numerical values.
Please feel free to let us know if you still have any questions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/10/2016 Posts: 1
|
Thank you very much for explaining the dimension calculations. I've confirmed that fix is working and that images returned are actually zoomed in when ZoomLevel is set.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great! Thanks for confirming the fix! Please feel free to let us know if there is anything else.
|
|