|
Rank: Newbie Groups: Member
Joined: 2/6/2014 Posts: 5
|
Hi, I hope someone is able to help. I seem to have a problem with a really simple piece of html when trying to convert it to PDF. The latest versions of Chrome, firefox and IE all render this correctly in print preview, but EO.Pdf seems to not like it. It is two simple full height tables (which are the basis of our current online billing system, one table per bill) which should be a two page document, with one table on each page. Quote:<!DOCTYPE html> <html style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body style="height: 100%; margin: 0px;">
<table border="1" style="border-collapse: collapse;height: 100%;"><tr><td>Full Height Test Page 1</td></tr></table> <table border="1" style="border-collapse: collapse;height: 100%;"><tr><td>Full Height Test Page 2</td></tr></table>
</body> </html> I'm using the following code to render the pdf: Quote: EO.Pdf.HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4 EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(0.0F, 0.0F, 8.267F, 11.629F) HtmlToPdf.ConvertUrl("http://xx.xx.xx/test.htm", "C:\test.pdf") Can anyone shed any light on this? I've yet to find an html to pdf component that can render our bills correctly. Thanks Julian
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You should not use full height in your HTML. Browser window has a known height so it is able to honor full height based on that information. The HTML to PDF converter does NOT has a known height. It only tries to layout all HTML elements from top to the bottom. It can not assume a 100% height is a full page height either as the converter applies zoom factors (since a screen is typically wider than a paper). If you want to precisely control the table's size and location, you need to control zoom factor and apply manual page break. You can find more information about zoom factor here: http://www.essentialobjects.com/doc/4/htmltopdf/auto_fit.aspxAnd manual page break here: http://www.essentialobjects.com/doc/4/htmltopdf/paging.aspxHope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 2/6/2014 Posts: 5
|
Thanks for the quickly reply. eo_support wrote:The HTML to PDF converter does NOT has a known height. Ummm, "EO.Pdf.HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4" was specified so the converter knows the size of each page of the document, which is 8.267inches x 96dpi = 793.632 pixels by 11.629inches x 96dpi = 1116.384pixels, just like my browser knows that I have a the window open at 793x1116, so could you run the problem by me again? If I do the following: Quote: EO.Pdf.HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4 EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(0.0F, 0.0F, 8.267F, 11.629F) EO.Pdf.HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.ScaleToFit EO.Pdf.HtmlToPdf.Options.ZoomLevel = 1 I get a one page document (not two pages as expected) with the table reading "Full Height Test Page 1" filling the full height of the page so the HTML to PDF converter clearly knows the height of the page.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
No. The HTML to PDF converter does not have a "full height" value. The HTML to PDF converter works in stages: Layout -> Pagining/Scaling -> Rendering. At layout stage, the HTML to PDF converter arrange/position all elements. After that it gets the full content height based on the result of this stage. It then use this height value to page or scale. If you do not set ScaleToFit, then it compare this content height value with the page height, if content height is more than page height, then paging occurs. If you set ScaleToFit, then it use the content height and page height to derive a scale factor and scale the output to fit the page.
In order for 100% height o be layouted correctly, the full height value must be known at layout stage. For browser this is the window height so it is known at layout stage. This is not the case for the HTML to PDF converter. There is no full height value used by the HTML to PDF converter at this stage.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 2/6/2014 Posts: 5
|
Thanks for the insight into how the renderer works, that has enabled me to work around the problem.
I am now setting the table height to a known number of pixel for A4 paper (1116px at 96dpi) and its working with one bill per page now.
Thanks again!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are very welcome. Glad to hear that you got it work!
|
|