Rotate pdf pages: 90 degree for even pages and -90 degree for odd pages

With pdftk version 1.45 (6 December 2012) or later, use:

pdftk A=MyPdfFile.pdf shuffle AoddWest AevenEast output MyRotatedFile.pdf

If you have pdftk version 1.44 (thanks to Gilles for pointing that out!), you can use:

pdftk A=MyPdfFile.pdf shuffle AoddL AevenR output MyRotatedFile.pdf

Some similar example cases are described in man pdftk (at least in recent versions).


This is easy since pdftk 1.44 which added the shuffle operation allowing different transformations on odd and even pages (amongst other uses).

If you have an older version of pdftk, you can use this Python script with the PyPdf library. (Warning, typed directly into the browser.)

#!/usr/bin/env python
import sys
from pyPdf import PdfFileWriter, PdfFileReader
input = PdfFileReader(sys.stdin)
output = PdfFileWriter()
for i in range(0,input.getNumPages()):
    output.addPage(input.getPage(i).rotateClockwise(90 if i%2==0 else -90))
output.write(sys.stdout)

Tags:

Pdf

Pdftk