![]() The alternatives include making a regular first pass (normal media size) and determining the total length at the end, then making a second pass with the extended media size or making a wkHTMLtoImage pass first to determine media size or somehow gluing together regular pages into one or simply oversizing the media and cropping the result afterwards. You would need to make a second pass to update all y-coordinates to have y=0 at the bottom of the long page (as well as reset the MediaBox). That's no problem for a fixed media size, but trying to build a page of unknown media length means that sooner or later you will go negative on your coordinates. It's too bad that Adobe chose to do this (almost every other graphics system has y=0 at the top). Thus, the y-coordinate of the top of the page needs to be known when you start. One aspect of unlimited page length is that, while pages are built from the top down, the coordinate system runs from the bottom up. I will continue to follow this thread with interest :) None of my documents have exceeded 508cm. I got the best results when calculating 1px width = 0.0333333 and 1px height = 0.04.Īnd needless to say. However I found that when setting the height it's actually a little bit bigger in the resulting PDF. It's not 100% perfect but works well enough in my case so thought someone else would be interested in this while we keep waiting for a potential fix to this issue. And then setting the page_height and page_width to the HTML-document size by calculating the pixels to cm. I worked around this problem by setting all page margins to zero with the margin_top, margin_bottom, margin_left, margin_right parameters. Too bad since this would be a great feature that is requested a lot. This thread has been inactive for a long time since my last post. Is there any way this can be done now? There is a chance I've missed something in the docs. If wkhtmltoimage could export to PDF or wkhtmltopdf supported something like -auto-size to get custom-sized single-paged documents, the solution to the problem I describe would be possible. ![]() Thus, the situation is resolved only partially in both scenarios. However, it is impossible to tell wkhtmltopdf to keep the size of a page minimum, so I can’t start using this script instead of wkhtmltoimage as automatically defined dimensions of an image are in priority. If I try to convert HTML to PDF in one step using wkhtmltopdf, the links remain, which is great (thanks to a new feature). Resulting files are then used in a latex project, that’s the reason why they can’t be raster or have predefined dimensions.Īll works fine except one thing: the links defined in the HTML get lost. First, I get an SVG using wkhtmltoimage and then convert it to PDF with inkscape. As mentioned earlier, to get a PDF of a minimum possible size, I'm doing HTML conversion in two steps.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |