1.0.4 • Published 6 years ago

pdf-form-utils v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

PDF Form Utils for Node.js

A node.js toolkit that wraps PDFTk to expose two essential utilities - generating a list of form fields in a pdf form and filling a pdf form using a JS object.

NPM

Environment

  • You must have pdftk binary in your $PATH
  • Requires Node.js >= 8.11.0

Usage example of reading form Fields

const { getFields } = require("pdf-form-utils")

console.log(getFields(sourcePath)) // path.resolve recommended for sourcePath

Usage example of filling a PDF form with Express

const fs = require("fs")
const app = require("express")()
const { generatePDF } = require("pdf-form-utils")

app.get('/form', (req, res, next) => {
  generatePDF(data, sourcePath, destinationPath, err => {
    if (err) next(err)
    else {
      res.contentType('application/pdf')
      res.download(destinationPath, 'form.filled.pdf', err => {
        if (err) next(err)
        fs.unlinkSync(destinationPath) // Delete the temporary file
      })
    }
  })
})

Acknowledgements

For JS-to-FDF transform: utf8-fdf-generator

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago