How to Merge and Extract PDF Pages on Linux Like a Pro

0saves

📄 How to Merge and Extract PDF Pages on Linux Like a Pro

Working with PDF files on Linux is easier than you think. Whether you need to merge multiple PDFs into a single file or extract specific pages (even in reverse order!), Linux has powerful and free tools to get the job done.

Here’s your ultimate guide to merging and extracting PDF pages using the command line.


🔧 Tool of Choice: pdftk

✅ Install pdftk on Ubuntu Linux:

sudo apt update
sudo apt install pdftk

📚 Merge Multiple PDF Files into One

If you have several PDFs and want to combine them:

pdftk file1.pdf file2.pdf file3.pdf cat output merged.pdf

This command will create a new file called merged.pdf containing all pages from file1.pdf, file2.pdf, and file3.pdf in that order.


✂️ Extract Specific Pages from a PDF

Example: Extract pages 1 to 5

pdftk input.pdf cat 1-5 output output_pages_1_to_5.pdf

Extract specific non-consecutive pages:

pdftk input.pdf cat 1 3 5 output selected_pages.pdf

🔁 Extract Pages in Reverse Order

Let’s say you want to extract the first five pages from input.pdf but in reverse order—page 5 becomes 1, page 4 becomes 2, etc.

pdftk input.pdf cat 5 4 3 2 1 output reversed_pages_1_to_5.pdf

🐚 BONUS: Bash Script to Reverse Page Ranges

Want to automate reversing a range of pages? Here’s a neat bash snippet:

START=1
END=5
REVERSED=$(seq $END -1 $START | tr '\n' ' ')
pdftk input.pdf cat $REVERSED output reversed_range.pdf

💡 Alternatives

If you want GUI or extra formatting features, check out:

  • PDF Arranger – GUI tool to merge/reorder visually

    sudo apt install pdfarranger
  • qpdf – powerful CLI tool:

    qpdf input.pdf --pages . 5-1 -- reversed.pdf

🏁 Final Thoughts

With tools like pdftk, qpdf, and pdfarranger, working with PDFs on Linux becomes a breeze. Whether you’re splitting, merging, or reordering pages, there’s no need for paid or proprietary software.

Got a favorite PDF tip or tool on Linux? Drop it in the comments and let’s build an even better toolbox together! 🧰🐧

Leave a Reply

Your email address will not be published. Required fields are marked *