pofider / phantom-html-to-pdf

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

How do I generate .pdf file using this? #73

Closed ishwarrimal closed 7 years ago

ishwarrimal commented 7 years ago

There is not much description on generating .pdf file from html. I was using html-pdf where i could provide the name of the file that i want to generate and other stuff. I am quite lost in this. Please help me out.

pofider commented 7 years ago
var conversion = require("phantom-html-to-pdf")();
conversion({ html: "<h1>Hello World</h1>" }, function(err, pdf) {
  console.log(pdf.logs);
  console.log(pdf.numberOfPages);
  pdf.stream.pipe(res);
});

The package offers stream in callback, save it to file with name of your wish.