MeteorPackaging / pdftk

PDF toolkit - split, merge, rotate, watermark, stamp and secure PDF pages and documents
https://atmospherejs.com/pdftk/pdftk
48 stars 4 forks source link

PDFTk

Server-side Meteor wrapper for PDFtk, the PDF toolkit, a tool for manipulating PDF documents.

From the pdftk man page:

If PDF is electronic paper, then pdftk is an electronic stapler-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents. Keep one in the top drawer of your desktop and use it to:

  • Merge PDF Documents or Collate PDF Page Scans
  • Split PDF Pages into a New Document
  • Rotate PDF Documents or Pages
  • Decrypt Input as Necessary (Password Required)
  • Encrypt Output as Desired
  • Fill PDF Forms with X/FDF Data and/or Flatten Forms
  • Generate FDF Data Stencils from PDF Forms
  • Apply a Background Watermark or a Foreground Stamp
  • Report PDF Metrics such as Metadata and Bookmarks
  • Update PDF Metadata
  • Attach Files to PDF Pages or the PDF Document
  • Unpack PDF Attachments
  • Burst a PDF Document into Single Pages
  • Uncompress and Re-Compress Page Streams
  • Repair Corrupted PDF (Where Possible)

Requirements

You need to have PDFTK installed on the system. Downloads for all operating systems are available at https://www.pdflabs.com/tools/pdftk-server/. For Linux, you can also run sudo apt-get install pdftk (make sure you get the latest version).

Quick Start

Add the package with meteor add pdftk:pdftk. In your server code, you can run wrappers like this:

PDFTK.stamp('/path/to/in.pdf', '/path/to/stamp.pdf', '/path/to/pdfstamp/out.pdf', function (error, stdout, stderr) {
  if (error) console.log('Error:', error);
  else {
    // success
  }
})

Note that you need to pass absolute paths to the files because the current directory when running meteor is going to be .meteor/local/build/programs/server/ when debugging, and something similar in production.

Command wrappers

Consult the man page for command details.

Pull requests are welcome for more wrappers. If you need to execute a custom command, or one that's not wrapped, run:

Documentation

More information about PDFTK:

Contributing

Contributors are very welcome. Some guidelines below:

TODO

  1. Make sync version
  2. Wrap more commands
  3. Document the Buffer return value - anything we can actually do with it, vs. the callback?

Contributors

License

MIT