0.0.1 • Published 10 months ago

pdf-reporter v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Pdf Reporter


A wrapper to puppeteer and handlebars to conviniently create pdf reports with only one method.

This small package is inspired by PugJs. It also makes use of Puppeteer-report to handle headers and footers better.


Installation:

yarn add pdf-reporter

Usage

import {getPdfReport} from 'pdf-reporter';

getPdfReport(browserContext, handlebarsTemplatePath, templateData, options?)
    .then(pdfBuffer => console.log(pdfBuffer))

The parameters are:

  • browserContext: a puppeteer browserContext
  • handlebarsTemplatePath: a path (relative or absolute) to your handlebars template file
  • templateData: the template's specific data to be used
  • options: puppeteer's PDFOptions

Notice: this wrapper doesn't use puppeteer's original pdf method; it makes use of Puppeteer-report, making the handling of header and footer easier (and some of PDFOptions useless).