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

cannot it create html from a stream? #568

Open ORESoftware opened 4 years ago

ORESoftware commented 4 years ago

Right now the api is like so:

var html = fs.readFileSync('./test/businesscard.html', 'utf8');
var options = { format: 'Letter' };

pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) {
  if (err) return console.log(err);
  console.log(res); // { filename: '/app/businesscard.pdf' }
});

is there a way to input a stream, like this:

const html = fs.createReadStream('./test/businesscard.html', 'utf8');  // readable stream here!
const options = { format: 'Letter' };

pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) {
  if (err) return console.log(err);
  console.log(res); // { filename: '/app/businesscard.pdf' }
});
giovanni-bertoncelli commented 3 years ago

I need this too! @ORESoftware have you found any alternative?

ORESoftware commented 3 years ago

i have a working solution if you want but its in a private repo, but i can copy the important part here

HighSoftWare96 commented 3 years ago

Thank you but at the end I've used puppeteer with a temporary HTML file..

devcaco commented 3 years ago

i have a working solution if you want but its in a private repo, but i can copy the important part here

I'm interested in your working solution, is there anyway you can share it?