1.0.3 • Published 5 years ago

node-html-to-pdf v1.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

Generate PDF's using HTML

Usage:

import PDF from 'html-to-pdf';

var pdf = new PDF({
  templatePath: string,
  data: {} // Data to parse into template
  options: {
    puppeteerPDFOptions: { path: './my.pdf' },
    puppeteerLaunchOptions: { executablePath: '/usr/local/chromium' },
    handlebarsCompileOptions: {}
  }
});

var mypdf = pdf.build();

For puppeteerPDFOptions see Puppeteer's Docs

For puppeteerLaunchOptions see Puppeteer's Docs

For handlebarsCompileOptions see Handlebars' Docs

Save PDF

To save the PDF define options.puppeteerPDFOptions.path. This will result in pdf.build() returning the same path.

Get PDF as Buffer

To get the PDF as a Buffer leave options.puppeteerPDFOptions.path blank. This will result in pdf.build() returning a Buffer.