fill-xpdf

0.0.3 • Public • Published

fill-xpdf

A node module to fill out PDF forms using XFDF model format (utf8 compatible).

It uses pdftk to fill out PDF forms.

Installation

npm install fill-xpdf

Dependencies

You need to have the pdftk binary in your PATH.

Install on Mac OSX

Install on Ubuntu/Debian

sudo apt-get install pdftk

Usage example (with express)

const fillPdf = require("fill-xpdf");
const formData = { FieldName: 'Text to put into form field' };
const pdfTemplatePath = "templates.pdf";
 
app.get('/filled_form.pdf', (req, res) => {
  fillPdf.generateXPdf(formData, pdfTemplatePath, function(err, output) {
    if ( !err ) {
      res.type("application/pdf");
      res.send(output);
    }
  });
});

Passing Custom Arguments to pdftk

For more specific uses, you can also pass some extra arguments to pdftk. It is done by specifying them as an array, given as a third argument of the fillPdf function.

For instance, if you want to make the output PDF not editable anymore, you can append the flatten argument such as:

const fillPdf = require('fill-xpdf');
 
const extraArgs = ['flatten'];
fillPdf.generateXPdf(formData, pdfTemplatePath, extraArgs, (err, output) => {
  // ...
});

Take a look on man pdftk to get a list of all available arguments.

Acknowledgements

Based on fill-pdf

Readme

Keywords

Package Sidebar

Install

npm i fill-xpdf

Weekly Downloads

51

Version

0.0.3

License

MIT

Unpacked Size

115 kB

Total Files

9

Last publish

Collaborators

  • henomis