qpdf
works great and is super fast!:
Tested on Ubuntu 20.04 with qpdf version 8.0.2 (see qpdf --version
), but I suspect it would work fine on Ubuntu 18.04, 16.04, and 14.04 too, since I've used qpdf
in other ways on all of those systems as well.
sudo apt update
sudo apt install qpdf
# Rotate in.pdf +90 deg and save as out.pdf
qpdf --rotate=+90 in.pdf out.pdf
# Rotate in.pdf -90 deg and save as out.pdf
qpdf --rotate=-90 in.pdf out.pdf
# Rotate in.pdf +/-180 deg and save as out.pdf
qpdf --rotate=+180 in.pdf out.pdf
The manual pages (man qpdf
) show very little, but what they do show is very important. Here's a key part right at the end of it (emphasis added):
For a summary of qpdf's options, please run qpdf --help
. A complete manual can be found in /usr/share/doc/qpdf/qpdf-manual.html or /usr/share/doc/qpdf/qpdf-manual.pdf.
So, read the full manual which is stored locally on your computer! Here are the links. Copy and paste them into your browser's address bar to open them. You can also view the manual online here: https://qpdf.readthedocs.io/.
- Local QPDF manual location on Linux:
- QPDF User manual in PDF form: file:///usr/share/doc/qpdf/qpdf-manual.pdf
- QPDF User manual in HTML form: file:///usr/share/doc/qpdf/qpdf-manual.html
To see the help options, run qpdf --help
instead. Or, even better, pipe to less
:
qpdf --help | less -RFX
Then you can press /
and search for --rotate
. Here's a snippet from the help pages:
--rotate=[+|-]angle[:page-range]
rotate each specified page 90, 180, or 270 degrees;
rotate all pages if no page range is given
and:
The --rotate
flag can be used to specify pages to rotate pages either
90, 180, or 270 degrees. The page range is specified in the same
format as with the --pages
option, described below. Repeat the option
to rotate multiple groups of pages. If the angle is preceded by +
or -
,
it is added to or subtracted from the original rotation. Otherwise, the
rotation angle is set explicitly to the given value.
References:
qpdf --help | less -RFX
- This answer by @Royi
- QPDF on GitHub
- Manual of QPDF (more extensive than
man
page)
Related
- My answer: How to extract PDF pages by page number or range of page numbers
qpdf
to work great and be super fast. I tested it on Ubuntu 20.04 too. See 1) this answer, and 2) my answer, with additional info. and examples.