Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was wondering in a pdf file, how to rotate pdf pages: 90 degree for even pages and -90 degree for odd pages?

By pdftk, all I know is to rotate a page by pdftk in.pdf cat 1W output out.pdf, and rotate all pages by pdftk in.pdf cat 1-endW output out.pdf.

Thanks!

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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)
share|improve this answer
    
What a nice pdf python processing example :) –  Grzegorz Wierzowiecki Dec 11 '11 at 9:13

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).

share|improve this answer
    
The shuffle command is new in pdftk 1.44, released in October 2010, so it's far from having reached all distributions yet. Before that, there was no convenient way of doing such collations with pdftk. –  Gilles Aug 12 '11 at 12:34
    
@Gilles I see. Thanks for pointing this out! (updated) –  rozcietrzewiacz Aug 12 '11 at 13:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.