View Full Version : QPDF is SUPER excellent PDF command line utality for Linux !!! Do you know it ??

9th March 2017, 10:38 AM
Hi. I discover a hidden (as I think) CLI PDF tool.

It is SUPER excellent tool, being very powerful, able to perform highly difficult & specific operations on PDF files ....... .

With this utility + Okular + jPDF Tweak, Linux system is not poor in support for PDF manipulation at all.

It is available in Fedora repositories.

Here it's sites:




Just look for it's manual:


Please notice that NOT EVERY THINGS included in this manual. There are many very powerful abilities not included in it (look for chapters 5 "Using QPDF Library" & chapter 6 "Design & Library Notes"). These beyond my understanding after rapid reading.

I will post here what I think the most important commands:

To remove PDF restrictions:
$ qpdf --decrypt infile.pdf outfile.pdf

To remove PDF user (open) password (you should already know it):
$ qpdf --password=userpassword --decrypt infile.pdf outfile.pdf

To encrypt PDF file:
$ qpdf --encrypt user-password owner-password key-length [restrictions] -- infile.pdf outfile.pdf

Note: “--” terminates parsing of encryption flags and must be present even if no restrictions are present. Either or both of the user password and the owner password may be empty strings. The value for key-length may be 40, 128, or 256. When no additional restrictions are given, the default is to be fully permissive.
Password-protected files may be opened by specifying a password. By default, qpdf will preserve any encryption data associated with a file. If --decrypt is specified, qpdf will attempt to remove any encryption information. If –encrypt is specified, qpdf will replace the document's encryption parameters with whatever is specified.
Note that qpdf does not obey encryption restrictions already imposed on the file. Doing so would be meaningless since qpdf can be used to remove encryption from the file entirely.
The restriction flags are dependent upon key length.
If key-length is 256, the minimum PDF version is 1.7 with extension level 8, and the AES-based encryption format used is the PDF 2.0 encryption method supported by Acrobat X.

Determines whether or not to allow accessibility to visually impaired.

Determines whether or not to allow text/graphic extraction.

Controls printing access. print-opt may be one of the following:
• full: allow full printing
• low: allow low-resolution printing only
• none: disallow printing

Controls modify access. modify-opt may be one of the following, each of which implies all the options that follow it:
• all: allow full document modification
• annotate: allow comment authoring and form operations
• form: allow form field fill-in and signing
• assembly: allow document assembly only
• none: allow no modifications
If specified, any metadata stream in the document will be left unencrypted even if the rest of the document is encrypted. This also forces the PDF version to be at least 1.5.
If specified, qpdf sets the minimum version to 1.7 at extension level 3 and writes the deprecated encryption format used by Acrobat version IX. This option should not be used in practice to generate PDF files that will be in general use, but it can be useful to generate files if you are trying to test proper support in another application for PDF files encrypted in this way.
The default for each permission option is to be fully permissive.

To show document encryption parameters (also shows the document's user password if the owner password is given):
$ qpdf --show-encryption file.pdf

To combine all pages in a set of files (merge multiple PDF files into single PDF):
$ qpdf --empty --pages *.pdf -- output.pdf

To extract a pages range of PDF to single PDF, with preserving their metadata:
$ qpdf infile.pdf --pages infile.pdf 1-10 -- output.pdf

To extract a pages range of PDF to single PDF, without their metadata:
$ qpdf --empty --pages infile.pdf 1-10 -- output.pdf

To take pages 1–5 from file1.pdf and pages 11–15 from file2.pdf in reverse:
$ qpdf file1.pdf --pages file1.pdf 1-5 file2.pdf 15-11 -- outfile.pdf

Note: the page range is a set of numbers separated by commas, ranges of numbers separated dashes, or combinations of those. The character “z” represents the last page, while the character “l” represent the first page. Pages can appear in any order. Ranges can appear with a high number followed by a low number, which causes the pages to appear in reverse. Repeating a number will cause an error.
Example page ranges:
• 1,3,5-9,15-12: mean pages 1, 2, 3, 5, 6, 7, 8, 9, 15, 14, 13, and 12.
• you can specify single page only.
• z-1: mean all pages in the document in reverse.

To repair a PDF:
$ qpdf infile.pdf outfile.pdf

To linearize a pdf:
$ qpdf --linearize infile.pdf outfile.pdf

To remove linearization (objuct streams) from PDF:
$ qpdf --object-streams=disable -qdf infile.pdf outfile.pdf

The tool is still under active development, so send your idea to the developer to be included.

Repeatedly I asked for such tool, but no one mention it here !! Fo that I post about it now because I think that it is not well known.

More & more my need for Windows OS programs for manipulating PDF files decreasing over time by discovery of such tools.

9th March 2017, 02:15 PM

Thanks for this tip. I had no idea such a powerful program existed!

12th March 2017, 04:13 PM
Hi. I discovered an error in manual of this great utilities ! It is related to VERY VERY VERY important function: combine (merge) multiple PDF files into single PDF. I edit my 1st post & correct nessessary command - that given wrongly in manual - & put it in RED BOLD font.

Please notice that this golden command RE-SIZE pages of all input PDF files & set them to same universal size in the output PDF file !!! Great !!! Very strong !!!

31st May 2020, 12:27 AM
If QPDF can ATTACH FILES like PDFTK so please tell me thanks

31st May 2020, 10:47 AM
If QPDF can ATTACH FILES like PDFTK so please tell me thanks

Hi dear.
I don't think that QPDF currently able to attache files within PDF. But you can request this from it's developer at:

Please notice that there is a GUI for QPDF in the road to become advanced GUI for QPDF. It is PDF Mix Tool:

You can install it as flatpak from FlatHub.

It is still in beginning of road, but it is promising ... It's developer working very hardly to add new features to it ...
There are other GUI programs that utilize QPDF but no one of them accept to be advanced GUI for QPDF ...

4th June 2020, 02:27 AM
I don't think that QPDF currently able to attache files within PDF
The pdfattach command from the poppler-utils package (available in the Fedora repos) can attach files to a PDF. I've been using poppler-utils for a long time to do PDF manipulations (extract, merge, etc.), but I'll give qpdf a try. I have used the qpdfview PDF reader (Qt-based GUI), and it seems decent, though I still prefer Acrobat Reader (which still runs on Fedora).