LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-27-2016, 07:33 AM   #1
knuno
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Rep: Reputation: 0
Rotate every second page of a pdf-document


I have several thousand 2-page PDF-files where the second page is rotated 180 degrees relative to the first. I would like to rotate the upside down page so that I have a nice straight forward document. I am able to do this using several Imagemagic commands per document:

convert -density 300x300 original.pdf[0] scra01.pdf
convert -density 300x300 -rotate 180 original.pdf[1] scra02.pdf
convert -density 300x300 scra01.pdf scra02.pdf new_complete.pdf

But can I do this in one command?

Knut
 
Old 04-27-2016, 08:33 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Hi!

If it is the second document always, you can use a loop and a counter, and only change those documents (pdfs) who are even numbered (based on the counter).

In pseudo code:
Code:
counter = 0
for doc in directory; do
    counter++
    if counter is even; then
        rotate doc
    else
        continue
    fi
done
Best regards,
HMW
 
Old 04-27-2016, 08:39 AM   #3
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 868
Blog Entries: 26

Rep: Reputation: 527Reputation: 527Reputation: 527Reputation: 527Reputation: 527Reputation: 527
@HMW: The OP wants to rotate *pages* in a document, not documents.

PDFTK has options to rotate single pages.
From the man-page:
Quote:
rotate [<page ranges>]
Takes a single input PDF and rotates just the specified pages. All other pages remain unchanged.
The page order remains unchaged. Specify the pages to rotate using the same notation as you would
with cat, except you omit the pages that you aren't rotating:

[<begin page number>[-<end page number>[<qualifier>]]][<page rotation>]

The qualifier can be even or odd, and the page rotation can be north, south, east, west, left,
right, or down.

Each option sets the page rotation as follows (in degrees): north: 0, east: 90, south: 180, west:
270, left: -90, right: +90, down: +180. left, right, and down make relative adjustments to a page's
rotation.

The given order of the pages doesn't change the page order in the output.
As regards graphical user-interfaces, PDF Mod lets you rotate single pages. I ignore if pdfchain (the GUI for pdftk) offers the option. You should opt for pdftk and automate the process for all your documents in a loop.

Edit: Okay, PDF Chain is cool, too. It lets you work on several documents simultaneously, select pages and manipulate only selected pages. Rotation is easy.

Last edited by Michael Uplawski; 04-27-2016 at 08:44 AM.
 
1 members found this post helpful.
Old 04-27-2016, 08:47 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
PDFtk looks fine, I would rather avoid convert pdf to image (makes text non searchable, non selectable etc)
 
Old 04-27-2016, 11:01 AM   #5
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by Michael Uplawski View Post
@HMW: The OP wants to rotate *pages* in a document, not documents.
Ah! Thanks for clarifying, my bad!

HMW
 
Old 04-27-2016, 01:08 PM   #6
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 868
Blog Entries: 26

Rep: Reputation: 527Reputation: 527Reputation: 527Reputation: 527Reputation: 527Reputation: 527
Quote:
Originally Posted by keefaz View Post
PDFtk looks fine, I would rather avoid convert pdf to image (makes text non searchable, non selectable etc)
There are reasons. See my blog.
 
Old 04-28-2016, 11:00 AM   #7
knuno
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
PDFtk or Imagemagic

Thank you for your answers and recomendation of PDFtk. I already looked into it and I'm quite sure it will do the job. But since Fedora 23, with KDE, do not have this in its standard repositories I found it a bit more of a hassle to install it. Besides I'm also curious as to how to work with multi page documents (PDF or TIFF) in Imagemagic.

Knut
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I display a tick in a pdf document. The document uses forms with tick choices. philp1863 Linux - Software 5 09-25-2014 09:47 AM
Extracting 1 page from a PDF Document dazdaz General 2 06-16-2012 10:51 AM
How to mark up a pdf document? taxpayer Linux - Software 7 08-15-2008 08:40 AM
Why i'm unable to rotate the page? Sahayam Linux - General 1 02-17-2008 11:57 PM
Using pdftk to get all first pages of many pdf's into one pdf document zest n zeal Linux - Newbie 1 01-15-2008 10:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration