Skip to content

Package for convert HTML to PDF by headless Chrome (puppeteer).

License

Notifications You must be signed in to change notification settings

vencakrecl/pdf-generator

Repository files navigation

PDF Generator

NPM package version License Last test status

Package for convert HTML to PDF by headless Chrome (puppeteer).

Installation

npm install @vencakrecl/pdf-generator

Demo

make run-demo
make run-demo-api ## HTTP server running on localhost:3001

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()

About

Package for convert HTML to PDF by headless Chrome (puppeteer).

Resources

License

Stars

Watchers

Forks

Packages

No packages published