@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/papyrusImport the makePapyrus function
makePapyrusrequires a configuration object which has the following interface:{ template: string, outputOptions: Record<string, any> }templateis the Pug template to useoutputOptionsis the options to pass to Puppeteer for PDF Generation (see the interface for theoptionsobject forpage.createPDFStreamhere)// In your TypeScript or JavaScript fileimport makePapyrus from '@skulpture/papyrus'const papyrus = makePapyrus(configuration)Use the resulting Papyrus object
papyrus.print(data, transform)datais the data you want to printtransforman optional function to transform the data to the shape required for the Pug template
Contribution
Contributions are welcome, just make a pull request