New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Div of page size render larger than page of the same defined size? #198
Comments
I am having the exact same issue |
Yes, very same problem! |
Yes, I can confirm I am encountering the same issue. |
+1 |
I had to use |
I'm guessing this relates to the PhantomJS update? See notes here.. #107 If it is the same issue, there's a long discussion at.. ariya/phantomjs#12685 Sounds like a real mess. There was an issue introduced in Phantom v1.9 with a fix in v2.0 but apparently v2.0 also introduced a related but different issue, with similar similar symptoms, that affected different platforms. TL;DR: There's a lot of confusion. The solution @marcbachmann mentions is popular. For me the magic number was 0.72: html { zoom: 0.72; } |
@molomby It certainly looks like the issue. Playing around on my machine (MacBook Air 13", 10.12.1) it is about 0.65. I suspect I'll need to tune this for each host I'll be deploying to? |
If you are going for A4 then check the aspect ratio on it (1:1.414). Then you can set
Also make sure that your elements don't have margin, because that can offset the whole page. |
There is still no resolution on that issue in the phantomjs repository. e.g. for Letter it is You could call that using The magic number is |
At this point I have moved on after having discovered puppeteer (developed by Google), which works well for my needs. See: https://www.npmjs.com/package/puppeteer I won't close this ticket, since there are likely to still be people wanting to see this ticket fixed. |
This module certainly doesn't fit everybody's need. I'm also using puppeteer a bit. 👍 |
on my side |
Thanks for the trick, 0.75 zoom worked for me too. |
Whether I try the html-pdf command or render the page from within the API, any elements I specify with a dimension end up being bigger than they should be. Essentially if I define a div to be the same dimensions of the page it still ends up being 30% bigger than the page.
The HTML, intending to fit within a single page of US letter size:
The JS I was using:
Using node-html-pdf version 2.1.0, MacOS X 10.12, NodeJS 6.7.0
The text was updated successfully, but these errors were encountered: