I am exporting a variable height web page to pdf using PhantomJS. Since pdf files can have any page size (rather, a relation, though, since it is vectorial), I would like to export it in such a way as to create a single page in pdf format that matches the entire web page.
Fortunately, using the evaluate method of evaluate , I can easily determine the page height.
page.includeJs('jquery.js', function() { var pageHeight = page.evaluate(function() { return $('#content').height(); }); });
However, I am not sure how I can use this to my advantage. viewportSize does not affect this in any way, since I am not showing viewport, but the entire document. I set it to a fixed {width: 800, height: 800}
Therefore, I cannot wrap my head around paperSize sizes. Setting the height of the returned page Height will display 1.5x pages, so I tried to change the width, but this actually does not match any formula I can understand.
Any ideas on how to achieve this, or you have more information about the correlation between the paperSize property and the pixel sizes displayed on the page
javascript pdf-generation phantomjs
treznik
source share