I am using following node module html-pdf to convert html to pdf. I have successfully converted html to pdf but I am having trouble downloading the file once it has been created.
Code to generate PDF:
var fs = require('fs');
var pdf = require('html-pdf');
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' }
});
How can I either open the PDF within the browser for the user to see or automatically download the pdf within the browser without the user having to go through another step.