Package for convert HTML to PDF by headless Chrome (puppeteer).
- JSON schema validation (ajv)
- Template engine (pug)
- CSS (bootstrap)
- HTTP server for static files (expressjs)
npm install @vencakrecl/pdf-generator
yarn add @vencakrecl/pdf-generator
make run-demo
make run-demo-api ## HTTP server running on localhost:3001
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()