pdftk
Master PDF operations with PDFtk, a powerful command-line tool. Learn to merge, split, encrypt, decrypt, and manipulate PDF files efficiently.
PDFtk - PDF Toolkit Command-Line Utility
PDFtk (PDF Toolkit) is a powerful command-line tool for manipulating PDF documents. It allows users to perform a wide range of operations, including merging, splitting, encrypting, decrypting, and rotating PDFs. This utility is invaluable for developers and system administrators who need to automate PDF processing tasks.
Merge PDF Files
Combine multiple PDF files into a single document. This is useful for consolidating reports, presentations, or any collection of documents.
# To concatenate all pdf files into one:
pdftk *.pdf cat output all.pdf
# To concatenate specific pdf files into one:
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
Manipulate Specific Pages
Extract or combine specific pages from PDF files, offering granular control over document content.
# To concatenate pages 1 to 5 of first.pdf with page 3 of second.pdf:
pdftk A=fist.pdf B=second.pdf cat A1-5 B3 output new.pdf
# To extract pages 2 to 3 from a file:
pdftk file.pdf cat 2-3 output file_with_page_2_and_3.pdf
Split PDF Files
Divide a single PDF document into multiple smaller files, either by page range or by individual pages.
# To split a PDF into single pages:
pdftk input.pdf burst output page_%03d.pdf
Encrypt and Decrypt PDFs
Secure your PDF documents by applying password protection or remove existing encryption.
# To encrypt a PDF with a user password:
pdftk input.pdf output encrypted.pdf owner_pw 12345 user_pw 67890
# To decrypt a PDF:
pdftk encrypted.pdf input_pw YOUR_PASSWORD input output decrypted.pdf
Additional PDF Operations
PDFtk supports many other operations, including rotating pages, filling form fields, and applying watermarks. Refer to the official documentation for a comprehensive list of commands and options.
For more advanced usage and detailed explanations, consult the official PDFtk documentation and resources like PDFtk Server Documentation and Stack Overflow discussions on PDFtk.