How can I use hummusJS to convert HTML code to PDF?
So far I am able to convert JPG images to pdf, as well as merge multiple pdfs.
HummusJS - Convert HTML page to PDF in JavaScript
1.3k Views Asked by Vipul Sharma At
2
There are 2 best solutions below
3

try to use html-to-pdf-converter
Using headless chrome via puppeteer and than modifying generated pdf via HummusJS to add headers and footers with page numbers
Install
npm install html-to-pdf-converter
For me node-html-pdf with phantomjs is the best.
Install
npm install -g html-pdf
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' }
});
puppeteer is a good solution:
Installation
Example - create a PDF.