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 543 forks source link

page orientation landscape issue #503

Open mushfau opened 5 years ago

mushfau commented 5 years ago

I'm generating a pdf in landscape orientation, with the content (an invoice) coming as html rendered via jsrender.

it works fine in my local environment (windows 10) the generated pdf is in landscape orientation.

but when deployed to production, in ubuntu, the generated pdf is in portrait mode, i have tried setting the page width and height too, instead of the option {format : 'A4'}.

below is my code...

let template = jsrender.templates('./path/to/invoice-template.html');
let html = template.render({order: order});
let options = {format: 'A4',orientation: 'landscape'};
let file = "./temp/F" + new Date().getTime() + ".pdf"

pdf.create(html, options).toFile(file, function (err, response) {
  if (err) {
   // handle error
  } else {
   // process download
  }
 });

what could be the possible cause, and solution?

uy commented 5 years ago

Hi, same problem in macOS Mojave(10.14.5). Can not test on server, for now.

Fixed from documentation.

alanaprianto commented 4 years ago

sampe problem in macOS catalina 10.15.3 :(