@skulpture/papyrus v0.1.3
About
A lightweight PDF renderer for Node.
Uses Pug and Puppeteer to render PDFs.
Features
- Compile HTML templates using Pug or bring your own templating engine ✅
- Render PDFs using Puppeteer or use a headless browser of your liking ✅
- Hookable PDF generation step ✅
Usage (with the defaults of Pug and Puppeteer)
Install Papyrus
$: npm i -S @skulpture/papyrus
Import the makePapyrus function
makePapyrus
requires a configuration object which has the following interface:{ template: string, outputOptions: Record<string, any> }
template
is the Pug template to useoutputOptions
is the options to pass to Puppeteer for PDF Generation (see the interface for theoptions
object forpage.createPDFStream
here)// In your TypeScript or JavaScript file
import makePapyrus from '@skulpture/papyrus'
const papyrus = makePapyrus(configuration)
Use the resulting Papyrus object
papyrus.print(data, transform)
data
is the data you want to printtransform
an optional function to transform the data to the shape required for the Pug template
Contribution
Contributions are welcome, just make a pull request