@mbrandau/htmlpdf
v0.0.1
Published
A library that converts HTML to PDF using Headless Chrome (puppeteer)
Downloads
6
Readme
htmlpdf
A library that converts HTML to PDF using Headless Chrome (puppeteer)
Gettings started
Installation
npm install --save @mbrandau/htmlpdf
Usage
The following example creates a PDF file of the index.html file.
const fs = require('fs');
const htmlPdf = require('@mbrandau/htmlpdf');
(async () => {
const options = {
format: 'Letter'
};
const pdfBuffer = await htmlPdf(fs.readFileSync('index.html'), options);
fs.writeFileSync('index.pdf', pdfBuffer); // Write PDF file
})();
Documentation
#htmlPdf(html[, options]) <Buffer> (async function)
Creates a PDF Buffer of the provided HTML using puppeteer. For available options see the puppeteer documentation.