LinuxCommandLibrary

qpdf

Transform and manipulate PDF files

TLDR

Extract pages 1-3, 5 and 6-10 from a PDF file and save them as another one

$ qpdf --empty --pages [path/to/input.pdf] [1-3,5,6-10] -- [path/to/output.pdf]
copy

Merge (concatenate) all the pages of multiple PDF files and save the result as a new PDF
$ qpdf --empty --pages [path/to/file1.pdf file2.pdf ...] -- [path/to/output.pdf]
copy

Merge (concatenate) given pages from a list of PDF files and save the result as a new PDF
$ qpdf --empty --pages [path/to/file1.pdf] [1,6-8] [path/to/file2.pdf] [3,4,5] -- [path/to/output.pdf]
copy

Write each group of n pages to a separate output file with a given filename pattern
$ qpdf --split-pages=[n] [path/to/input.pdf] [path/to/out_%d.pdf]
copy

Rotate certain pages of a PDF with a given angle
$ qpdf --rotate=[90:2,4,6] --rotate=[180:7-8] [path/to/input.pdf] [path/to/output.pdf]
copy

Remove the password from a password-protected file
$ qpdf --password=[password] --decrypt [path/to/input.pdf] [path/to/output.pdf]
copy

SYNOPSIS

qpdf [] --option-file=[filename] [inputfile] [outputfile]

PARAMETERS

--decrypt
    Decrypt an encrypted PDF file.

--encrypt
    Encrypt a PDF file.

--password=[password]
    Specify the password for decryption or encryption.

--linearize
    Linearize a PDF file for faster web viewing.

--split-pages
    Split a PDF file into individual pages.

--pages [inputfile] [page ranges]
    Extract specific pages from a PDF file.

--concatenate
    Concatenate multiple PDF files into one.

[inputfile]
    The input PDF file to process.

[outputfile]
    The output PDF file to be created.

--check
    Check a PDF file for errors.

--version
    Show qpdf version.

--help
    Display help message.

DESCRIPTION

qpdf is a command-line tool and C++ library for structurally transforming PDF files. It can perform a variety of operations including linearizing PDF files, encrypting and decrypting, splitting and merging, repairing damaged files, and inspecting their internal structure.

Its primary function is to take one or more PDF files as input and produce one or more new PDF files, optionally applying transformations. qpdf can be used to examine PDF objects, extract data, or manipulate page layouts. It is a versatile tool for both simple and complex PDF processing tasks and widely used for PDF repair and manipulation in scripting environments.

CAVEATS

Some PDF files may use features that qpdf does not fully support. Decryption may fail if the password is incorrect or the PDF uses advanced encryption algorithms.

ERROR HANDLING

qpdf provides informative error messages when encountering issues during processing, helping users to diagnose and resolve problems. It often indicates if there is a corrupt or malformed PDF structure.

MEMORY USAGE

Be aware of the potential memory usage when processing large PDF files with qpdf, especially when performing operations like linearization or splitting. Memory limitations can sometimes cause unexpected behavior.

HISTORY

qpdf was initially developed to address the need for a robust and flexible PDF manipulation tool. Over time, it has evolved through community contributions and continued development, gaining features to meet growing PDF processing needs. Its open-source nature has made it a valuable resource for developers and system administrators dealing with PDF files.

SEE ALSO

pdfinfo(1), pdftk(1)

Copied to clipboard