The html-pdf-chrome library is a modern replacement for the deprecated node-html-pdf package. It uses Puppeteer and headless Chrome instead of PhantomJS, providing better support for modern web standards.
| Feature | node-html-pdf | html-pdf-chrome |
|---|---|---|
| Engine | PhantomJS (deprecated) | Puppeteer/Chrome |
| CSS3 Support | Limited | Full |
| Modern Web APIs | No | Yes |
| Active Maintenance | No | Yes |
const pdf = require('html-pdf-chrome');
const html = fs.readFileSync('./test.html', 'utf8');
pdf.create(html, { format: 'Letter' })
.toFile('./output.pdf', (err, res) => {
console.log('PDF created:', res.filename);
});