jsreport / jsreport-phantom-pdf

jsreport recipe which is rendering pdf from html using phantomjs
GNU Lesser General Public License v3.0
11 stars 8 forks source link

Use phantom 2 #8

Closed postama closed 7 years ago

postama commented 7 years ago

With the macOS Sierra upgrade, phantom 1 is not working. How can we use this package with phantom 2.x?

pofider commented 7 years ago

1.npm install phantomjs-prebuilt

  1. render report with
{
  template: {
    phantom: {
      customPhantomJS: true
    }
  }
}
JonathanWilkins commented 7 years ago

Is there a way to do this globally for the instance of jsreport server as apposed to per template

pofider commented 7 years ago

This can be done using custom script

function beforeRender(req, res, done) {
   if (req.template.recipe === 'phantom-pdf') {
     req.template.phantom =  req.template.phantom || {}
     req.template.phantom.customPhantomJS = true
  }
  done()
}

Mark it as global in studio and it will do the job for all templates.

pofider commented 7 years ago

jsreport-phantom-pdf@1.3.0 now has global setting for this

"phantom": {   
    "defaultPhantomjsVersion": "2.1.1"
  }

The macOs sierra problem is also noted in the docs now http://jsreport.net/learn/phantom-pdf#macos-sierra