How to generate PDF of a website page with Node.js
In this article, we will see how easy it is to generate PDF of any webpage using Nodejs and send the generated pdf back to the client side application
Step 1
Step 1
$ npm install -g html-pdf
var fs = require('fs'); var pdf = require('html-pdf'); var html = fs.readFileSync('./mybus.html', 'utf8'); var options = { format: 'Letter' }; pdf.create(html, options).toFile('./mybus.pdf', function(err, res) { if (err) return console.log(err); console.log(res); // { filename: '/app/mybus.pdf' } });Nodejs Code example for Creating PDF of web Page
//mybus.html can replace with any html file. according to your application.

Comments
Post a Comment