fire-melo0n / node-html-to-pdf

Generate PDF's from HTML using Puppeteer and Handlebars.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Generate PDF's from HTML using Puppeteer and Handlebars.


Languages

Language:TypeScript 100.0%