Exchange odd and even pages in a pdf file?

Is it possible to exchange odd and even pages in a pdf file, e.g. page 1 and page 2 exchange, page 3 and page 4 exchange, …, assuming the pdf file has even number of pages?

Can it be done using some software e.g. pdftk or LaTeX?

Asked By: Tim


It seems like pdftk’s shuffle feature will do this. From man pdftk:

      shuffle [<page ranges>]
             Collates pages from input PDFs to create a new PDF.  Works
             like the cat operation except that it takes one page at a
             time from each page range to assemble the output PDF.

The general format for a [<page range>] is given as

<input PDF handle>[<begin page number>[-<end page number>[<qualifier>]]][<page rotation>]

where qualifier may be either even or odd. In the case that you wish to take alternating even and odd pages from the same document until all pages are exhausted, you can omit the <input PDF handle> and <begin page number>-<end page number> specifiers leaving just

pdftk infile.pdf shuffle even odd output outfile.pdf

where infile.pdf is the file whose pages are to be swapped and outfile.pdf is a name for the output.

Answered By: steeldriver

You can use qpdf

qpdf input.pdf --collate --pages . 1-z:even . 1-z:odd -- output.pdf

See QPDF Documentation.

Answered By: lezambranof
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.