@aalonzolu/htmlpdf

0.0.2 • Public • Published

htmlpdf

npm npm GitHub

A library that converts HTML to PDF using Headless Chrome (puppeteer)

Gettings started

Installation

npm install --save @aalonzolu/htmlpdf

Usage

The following example creates a PDF file of the index.html file.

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
})();

Documentation

#htmlPdf(html[, options]) <Buffer> (async function)

Creates a PDF Buffer of the provided HTML using puppeteer. For available options see the puppeteer documentation.

Readme

Keywords

Package Sidebar

Install

npm i @aalonzolu/htmlpdf

Weekly Downloads

9

Version

0.0.2

License

MIT

Unpacked Size

4.95 kB

Total Files

6

Last publish

Collaborators

  • aalonzolu