Friday, April 25, 2014

PDFTK, the Swiss army knife for managing PDFs

Merging and splitting of PDF documents and pages is something that I do quite regularly; for myself and for others who reach out to me to do my ninja thing with their PDFs. It's really not rocket-science though, to overuse an old adage.

The PDF Tool Kit is my application of choice for appending, merging and splitting PDF files. The most common situation I find myself using his tool is when I have disordered scanned pages, that needs to be arranged.

Here is an example with my passport, my resume and a few pay stubs, all in the PDF format. I need to send a few pages of each of these documents stitched together in a single PDF, to my HR department, for whatever  reason they want this information from me.
[mrigs@localhost ~]$ pdftk A=Passport.pdf B=Resume.pdf C=PayStubs2013.pdf cat A1 A18 B C11-12 A10 A14 A8 output Mriganka_HR.pdf
This is being run on a Mageia 4 Linux system. In this command
  • A=Passport.pdf is my Passport with 18 scanned pages
  • B=Resume.pdf is my resume of 4 pages
  • C=PayStubs2013.pdf is a PDF of my 2013 pay stubs, 1 for every month
  • cat is the command for concatenating PDFs together
  • A1 & A18 extracts the 1st and the 18th page of the passport, respectively
  • B extracts the whole resume and appends to the new PDF
  • C11-12 extracts my November '13 and December '13 pay stubs and appends to the new PDF
  • A10, A12 & A8 are my Visa pages from the passport that gets appended to the end of the new PDF
  • output Mriganka_HR.pdf is the final document that I need to send out to my HR

Quite simple, I'd say, and really very fast too, for completing this merge. For even easier use, there is also a GUI version of the tool available for the Windows platform.

From the pdftk man page on Mageia, here is a list of everyday PDF housekeeping that you can do with PDFTK.
  • 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, Bookmarks and Metadata
  • Add/Update PDF Bookmarks or 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)

Play around and you'd find quite some different usage of this Schweizer Offiziersmesser of PDF management.

Cheers, MT.

No comments:

Post a Comment

Thanks for reading. Please do comment if you feel like voicing your opinion or if you feel like we should know each other. It never hurts to befriend new people. Regards, Mriganka.