Edit PDFs on the Linux command line

Configurare noua (How To)

Situatie

Many of the documents you receive come in PDF format. Sometimes those PDFs need to be manipulated. For example, pages might need to be removed or added, or you might need to sign or change a specific page.

There are some fancy graphical user interface tools that let you edit PDFs, but I have always been most comfortable with the command line. Of the many command-line tools for this task, the ones I use when I want to modify a PDF are qpdf and poppler-utils.

Solutie

Pasi de urmat
Install

On Linux, you can install qpdf and poppler-utils using your package manager (such as apt or dnf.) For example, on Fedora:

$ sudo dnf install qpdf poppler-utils
qpdf

The qpdf command can do a lot, but I mostly use it for:

  1. Splitting a PDF into separate pages
  2. Concatenating, or combining, PDFs into one file

To split a PDF into separate pages:

qpdf --split-pages original.pdf split.pdf

This generates files like split-01.pdf, split-02.pdf, and so on. Each file is a single-page PDF file.

Concatenating files is a little subtler: qpdf –empty concatenated.pdf –pages split-*.pdf —

This is what qpdf does by default. The --empty option tells qpdf to start with an empty file. The two dashes (--) at the end signals that there are no more files to process. This is a case where the parameters reflect an internal model, rather than what people use it for, but at least it runs and produces valid PDFs!

poppler-utils

Tip solutie

Permanent

Voteaza

(3 din 5 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?