marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

Should mention clearly that this only works with PhantomJS 1.xx #98

Open prashcr opened 8 years ago

prashcr commented 8 years ago

I had to look in the package.json to figure it out why my pdf files ended up looking totally different.

Would be great if this could be included in the README

scurker commented 8 years ago

Can you be more specific about how it doesn't work? I'm using Phantom 2.1 and a pdf generates successfully although with different scaling than Phantom 1.9x. Is that the same issue you have?

prashcr commented 8 years ago

Thank you for your reply, and please accept my apologies for the terrible title.

I tried rendering the business card example, on my mac using Phantomjs 2.1. Apart from the black background, none of the CSS styles seem to have been applied.

I'll have a picture up in a bit, away from computer atm.

I tried rendering the same thing on an Ubuntu VPS using 1.9, and it rendered fine, just as shown in the example.

marcbachmann commented 8 years ago

Hmm. Are you using bootstrap? Any other css framework?

marcbachmann commented 8 years ago

oh. I should have read your comment. You ran the example. Will test that soon. ... It worked for me. The font is not the same size anymore. Looks like phantomjs changed the default pixel to inches ratio.

prashcr commented 8 years ago

Ah, that's probably it then. I didn't realize the font in the example wasn't web safe, so I thought the lack of the font was a CSS issue.

Also, I realized I'm on PhantomJS 2.1.1, not 2.1 Interestingly, this also happened while installing html-pdf Why does it do this if it's supposed to support v2? Even more peculiarly, I think it still ends up using the 2.1.1 PhantomJS available in my path even after installing 1.9.8

Found PhantomJS at /usr/local/bin/phantomjs ...verifying
PhantomJS detected, but wrong version 2.1.1 @ /usr/local/bin/phantomjs.
Download already available at /var/folders/dr/458p9zrj5xn06ssn6wzbqy840000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip
Verified checksum of previously downloaded file
Extracting zip contents
Removing /Users/prashanthcr/.nvm/versions/node/v5.5.0/lib/node_modules/html-pdf/node_modules/phantomjs/lib/phantom
Copying extracted folder /var/folders/dr/458p9zrj5xn06ssn6wzbqy840000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip-extract-1453864194321/phantomjs-1.9.8-macosx -> /Users/prashanthcr/.nvm/versions/node/v5.5.0/lib/node_modules/html-pdf/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /Users/prashanthcr/.nvm/versions/node/v5.5.0/lib/node_modules/html-pdf/node_modules/phantomjs/lib/phantom/bin/phantomjs
/Users/prashanthcr/.nvm/versions/node/v5.5.0/lib

Just to confirm, this is what you're seeing too? (2 separate pages)

screen shot 2016-01-27 at 10 48 56 am screen shot 2016-01-27 at 10 51 21 am

marcbachmann commented 8 years ago

Today I've released v2.0.0 that uses phantomjs v2.

@prashcr to generate the business card example, I've used a custom page size. I guess, you've used the default one. npm test currently runs all the examples and also rerenders the business card.