phantom-render-stream icon indicating copy to clipboard operation
phantom-render-stream copied to clipboard

Ignored settings due to opts was not extended to ropts

Open neofreko opened this issue 9 years ago • 1 comments

I was trying to set some config when initializing this package. But none of my setting was taken into account. I was trying to do this:

var phantom = require('phantom-render-stream')
var pr = phantom({
          format:'pdf',
          orientation: 'portrait',
          paperFormat : 'A4',
          paperSize: {
            width: '5in',
            height: '7in',
            margin: {
              top: '50px',
              left: '20px'
            }
          }
        })

Whatever value I changed there, the result didn't change at all. Apparently, these lines below basically ignore most of above values.

var initialize = function (url) {
      ropts = xtend({
        url        : url,
        quality:opts.quality,
        format     : opts.format,
        printMedia : opts.printMedia,
        expects    : opts.expects,
        timeout    : opts.timeout
      }, ropts);

Once it was changed to extend from opts, my result start transforming into what I had imagine it to be

neofreko avatar May 22 '15 22:05 neofreko

Just a heads up, some of the JSON options appear to not be applying at all. If paper related things are what you need, you'd be best off defining them within the paperSize option as an object. I had to do this to force landscape.

  var render = phantom({
      format: 'pdf',
      paperSize: {
        format: 'letter',
        orientation: 'landscape',
        margin: '0cm'
      }
  });

eastcoastcoder avatar Mar 28 '17 15:03 eastcoastcoder