aadamsx / meteor-pdftk

Meteor wrapper for PDFTk, the PDF Toolkit. PDFTk is a simple command line tool for doing everyday things with PDF documents like: merge, split, decrypt,encrypt, fill Forms, apply a background Watermark, report metrics, update PDF Metadata, attach files, unpack attachments, burst into single pages, uncompress and compress, repair corrupted PDF.
1 stars 0 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 aadams:pdftk. In your server code, you can run wrappers like this Please Note: this method calls out synchronous, by omitting the callback

PDFTK.stamp('/path/to/in.pdf', '/path/to/stamp.pdf', '/path/to/pdfstamp/out.pdf');

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.

The following APIs are meant to be use inside of Meteor methods.

Note: the first input to the cat wrapper is an arguments object, which takes up to 8 pdfs, the first two of which are required, in the following format: {first: pdf1, second: pdf2, third: pdf3, forth: pdf4, ...}.

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