pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

Allow for JS scripts to be injected #46

Closed Mardaneus86 closed 7 years ago

Mardaneus86 commented 7 years ago

This functionality allows you to inject JS files like the regular phantomjs implementation as proposed in issue #45. I've changed the parameter name to injectJs so it matches with the phantomjs implementation.

Usage:

  conversion({
    url: "http://example.com",
    injectJs: [
      __dirname + '/polyfill.js' // <-- include the full path to the script(s) to be injected
    ]
  }, function(err, pdf) {
    ...
  });

Unit tests are included for both phantom-server and dedicated-process implementations. Perhaps we could create a helper file to keep the strings in the test file and the file to be injected matched up.

pofider commented 7 years ago

Thank you, this looks great. I'll publish it to npm now.

pofider commented 7 years ago

Released in 0.4.10

Mardaneus86 commented 7 years ago

Great, thanks!