natjohan's blog

Posted mar. 24 septembre 2013

Tip of the week 24

Easily assemble, merge, extract your pdf files under linux with pdftk

pdftk, is a useful command line utility that allow to manipulate your pdf files. You can install it through your favorite package manager (example under Fedora)

natjohan# yum install pdftk

The syntax of pdftk is very simple :

pdftk <input_files_seperate_by_spaces> <operation> output <output_file>

Ok, so let's try it with two commons examples using cat operation :

Merge some pdf files

natjohan# pdftk A.pdf B.pdf C.pdf cat output ABC.pdf

Extract a page from a pdf file

natjohan# pdftk my_doc.pdf cat 4-6 output page4to6.pdf

Note that pdftk is a very powerful tool and it allow many operations (extract from the documentation)

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)

Pdftk GUI

You're afraid of using the command line ? no problem, there is a GUI called pdfchain, just install it with your package manager

natjohan# yum install pdfchain

Go further

man pdftk
CLI examples on the official website of pdftk
Pdfchain offical webpage
Category: ToTW
Tags: pdf assemble modify

Comments