PDF Generator
Package for convert HTML to PDF by headless Chrome (puppeteer).
Installation
npm install @vencakrecl/pdf-generator
Demo
make run-demo
make run-demo-api
Example
import { PdfGenerator } from '@vencakrecl/pdf-generator'
const createPdf = async () => {
const pdf = new PdfGenerator('base_dir')
await pdf.start()
pdf.addTemplate('test', 'template.pug', {
properties: {
title: {
type: 'string'
}
},
required: ['title']
})
const data = await pdf.generate('test', {title: 'Title'})
console.log(data)
await pdf.stop()
}
createPdf()