

pdftl
pdftl: A modern Python-based successor to pdftk. A CLI tool for PDF manipulation, merging, and geometry (crop/chop) powered by pikepdf and qpdf.
Cost / License
- Free
- Open Source (MPL-2.0)
Platforms
- Windows
- Mac
- Linux
- BSD
Features
Tags
- pdftl
- pdf-processing
- pdftk-alternative
- pikepdf
- python-pdf
- pdf-manipulation
- cli-app
- pdf-python
- qpdf
pdftl News & Activities
Recent activities
pdftl information
What is pdftl?
pdftl ("PDF tackle") is a CLI tool for PDF manipulation written in Python. It is intended to be a command-line compatible extension of the venerable pdftk.
Leveraging the power of pikepdf (qpdf) and other modern libraries, it offers advanced capabilities like cropping, chopping, regex text replacement, adding text and arbitrary content stream injection.
Quick start
pipx install pdftl[full]
merge, crop to letter paper, rotate last page and output with encryption with one command
pdftl A=a.pdf B=b.pdf cat A1-5 B2-end
--- crop '4-8,12(letter)'
--- rotate endright
output out.pdf owner_pw foo user_pw bar encrypt_aes256
pdftl maintains command-line compatibility with pdftk while introducing features required for modern PDF workflows.
Key features
📄 Standard operations
Combine: cat, shuffle (interleave pages from multiple docs). Split: burst (split into single pages), delete pages. Metadata: dump_data, update_info, attach_files, unpack_files. Watermarking: stamp / background (single page), multistamp / multibackground.
?? Geometry & splitting
Rotate: rotate pages (absolute or relative). Crop: crop to margins or standard paper sizes (e.g., "A4"). Chop: chop pages into grids or rows (e.g., split a scanned spread into two pages). Shift, scale and spin page content inside the page boundaries using place.
📝 Forms & annotations
Forms: fill_form, generate_fdf, dump_data_fields. Annotations: modify_annots (surgical edits to link properties, colors, borders), delete_annots, dump_annots.
🔐 Security
Decryption: using input_pw. Encryption: using owner_pw, user_pw and encrypt_aes256, optionally setting permissions with allow. Signatures: add secure signatures using sign_key and sign_cert. List and verify signatures using dump_signatures (powered by pyHanko).
🛠? Advanced
Text replacement: replace text in content streams using regular expressions (experimental). Code injection: inject raw PDF operators at the head/tail of content streams. Optimization: optimize_images (smart compression via OCRmyPDF). Dynamic text: add_text supports Bates stamping and can add page numbers, filenames, timestamps, etc. Cleanup: normalize content streams, linearize for web viewing. Extensibility: write your own custom operation in Python, save to ~/.config/pdftl/operations (*nix) or %APPDATA%\pdftl\config (windows)` and you can use it in pdftl, just like the built-in operations.



