How can I display html content in pdf format using phantomJs in node.JS

How can I generate a PDF file with some html content and display the file and content in a browser using phantom.js in node.js?

+5
source share
1 answer

Why not use the html-pdf npm module that uses phantomJS?

Code example

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' } }); 
+7
source

All Articles