PDF manipulation commands [Linux Terminal Cheatsheet]


1. Extract pages from pdf

Whether you want to split off a specific page from a pdf or extract a range of pages, this is the command for you:

pdftk full-pdf.pdf cat 13-17 output extracted-pages.pdf

2. Concatenate two pdfs

You can merge/concatenate two pdfs with the following command:

pdftk file1.pdf file2.pdf cat output concatenated.pdf

3. Convert jpeg to pdf

Option 1:

convert picture.jpeg -auto-orient newfile.pdf

Option 2:

This method works with jpg, jpeg, or png files.

img2pdf picture.jpg –output newfile.pdf

4. Make text searchable in an image pdf

If you have a pdf with pages that are only images of a written document, you won’t be able to select, highlight, or search the text. However, you can fix that by running OCR over the pdf document and adding a text layer.

ocrmypdf images.pdf images_ocr.pdf

The OCRmyPDF package is very useful and powerful.

Ricky Nave

In college, Ricky studied physics & math, won a prestigious research competition hosted by Oak Ridge National Laboratory, started several small businesses including an energy chewing gum business and a computer repair business, and graduated with a thesis in algebraic topology. After graduating, Ricky attended grad school at Duke University in the mathematics PhD program where he worked on quantum algorithms & non-Euclidean geometry models for flexible proteins. He also worked in cybersecurity at Los Alamos during this time before eventually dropping out of grad school to join a startup working on formal semantic modeling for legal documents. Finally, he left that startup to start his own in the finance & crypto space. Now, he helps entrepreneurs pay less capital gains tax.

Recent Posts