Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Main Support Categories > General Help
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

General Help
All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu.

 
Thread Tools Display Modes
Old September 23rd, 2008   #1
reader4
A Carafe of Ubuntu
 
Join Date: Jan 2007
My beans are hidden!
pdftk usage question

Sometimes when the librarians scan papers/books to send me, they get the orientation wrong and all of the even pages need to be rotated 180 degrees. I can rotate all of those pages using pdftk

Code:
pdftk in.pdf cat 1-endevenS output out.pdf
But how to 'cat' the odd pages back in, properly interleaved?

Using this just gives me the all the rotated even pages first, then the odd pages:

Code:
pdftk in.pdf cat 2-endevenS 1-endodd output out.pdf
reader4 is offline   Reply With Quote
Old May 2nd, 2009   #2
Tillmo
First Cup of Ubuntu
 
Join Date: Jan 2008
Beans: 2
Re: pdftk usage question

Use the following shell script. Save it as pdf-rotate-even and make it executable.

Code:
#/bin/bash
# script for rotating all even pages of a document

# enough arguments?
if [ $# -ne 2 ]; then
         echo 1>&2 Usage: pdf-rotate-even input.pdf output.pdf
         exit 127
    fi

# generate a temporary directory
TEMPDIR=/tmp/pdf`date +%N`
mkdir $TEMPDIR

# rotate all even pages, keep the odd ones
pdftk $1 cat 1-endodd output $TEMPDIR/odd.pdf
pdftk $1 cat 1-endevenS output $TEMPDIR/even.pdf

# split the files...
pdftk $TEMPDIR/odd.pdf burst output $TEMPDIR/pg%04d_A.pdf
pdftk $TEMPDIR/even.pdf burst output $TEMPDIR/pg%04d_B.pdf

# ... and recombine them, "_A" and "_B" suffixes leading to the correct order
pdftk $TEMPDIR/pg*.pdf cat output $2

# cleanup
rm -r $TEMPDIR
Tillmo is offline   Reply With Quote
Old October 6th, 2009   #3
fungs
First Cup of Ubuntu
 
Join Date: Sep 2009
Beans: 1
Re: pdftk usage question

Thanks for the script, I had the same problem.

I suggest du use evenD instead of evenS since it will rotate relatively by 180 degrees.
fungs is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:24 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry