A library that converts HTML to PDF using Headless Chrome (puppeteer)
npm install @aalonzolu/htmlpdfA library that converts HTML to PDF using Headless Chrome (puppeteer)
npm install --save @aalonzolu/htmlpdf
The following example creates a PDF file of the index.html file.
``js
const fs = require('fs');
const htmlPdf = require('@aalonzolu/htmlpdf');
(async () => {
const options = {
format: 'Letter'
};
const pupteerOptions = {}
const pdfBuffer = await htmlPdf(fs.readFileSync('index.html'), options,pupteerOptions);
fs.writeFileSync('index.pdf', pdfBuffer); // Write PDF file
})();
``
Creates a PDF Buffer of the provided HTML using puppeteer. For available options see the puppeteer documentation.