xxxxxxxxxx
// You can use the `html-pdf` package from npm to convert HTML to PDF in Node.js
// Install the package using npm (If not already installed)
// npm install --save html-pdf
const pdf = require('html-pdf');
const fs = require('fs');
const htmlContent = '<html><body><h1>Hello World!</h1></body></html>';
const options = {
format: 'Letter'
};
pdf.create(htmlContent, options).toFile('./output.pdf', function(err, res) {
if (err) return console.log(err);
console.log(res);
console.log('HTML to PDF conversion complete!');
});
// The converted PDF file will be saved as 'output.pdf' in the current directory
xxxxxxxxxx
npm install -g html-pdf
html-pdf test/businesscard.html businesscard.pdf
more in detailed info at: look at the source
https://github.com/marcbachmann/node-html-pdf/releases