I want to rearrange the pages in a PDF file. But because I have to rearrange many pages, and the new arrangement has a specific pattern, I would like to do so with a script. Is there a simple program which allows to rearrange the pages in a PDF?
Alternatively I could also extract all pages and merge them together in the order I want. What progams are available to do this?
pdftk
is the one you're searching for. E.g. if you want to reverse the page order ofi.pdf
, doOther examples showing
pdftk
's potential:Read
man pdftk
for more information.To install
pdftk
on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?If you after all search for a GUI solution have a look at
pdftk
's GUIpdfchain
orpdfmod
.You can also try
pdfjam
pdfnup
(based on LaTeX pdf-pages)Example:
{}
inserts an empty pageYou can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.
You can find more information and other examples here on pages 10 and 11.
qpdf works like a charm (tested under cygwin, don't say it), preserving the links within the pdf required me to not use the
--empty
option and to replace it with the input filename:(rN to select a page indexed from end, z for last page)