About the pdftk tools, we can read the options using –help.
We can see many examples and features… See the description of this tool.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | DESCRIPTION If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents. Use it to: * Merge PDF Documents * 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 Stencil 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) |
Let’s try some simple examples.
extract all the odd-numbered pages:
1 | $ pdftk your_input.pdf cat 1-endodd output new.pdf |
extract all the even-numbered pages:
1 | $ pdftk your_input.pdf cat 1-endeven output new.pdf |
extract the pages 25 to 30 and create a new pdf:
1 | $ pdftk your_input.pdf cat 25-30 output new.pdf |
extracting pages 20,25, and 30:
1 | $ pdftk your_input.pdf cat 20 25 30 output new.pdf |
extract all pages into separate individual pdf pages.
1 | $ pdftk your_input.pdf burst |
we want to have the password “hello” for opening the file
1 | $ pdftk your_input.pdf output new.pdf encrypt_40bit user_pw "hello" |
You can try it with any args of this command.