13

I want to rotate every odd page 180 degrees using pdfjam.

I do not want to use pdftk, as in this question. The command seems to be pdf180 (for pdfjam before version 3.02), but the selection does not seem to take rules like odd/even pages. Also, if I skip pages, the new document does not include them. Thus, the command

pdf180 file.pdf 1,3,5,7,9                # for pdfjam < 3.02
pdfjam --angle 180 file.pdf 1,3,5,7,9    # for pdfjam >= 3.02

produces a file without pages 2, 4, 6, and 8.

Also, I have a large document, so I would like to save space when writing this. I cannot see anything useful in pdfjam --help.

How can I achieve this goal?

If a one-line command cannot produce this, I guess I could write a script, which produces $N$ number of rotated files, and then merge them.

  • Strange, I have pdfjam installed but no pdf180. It seems I won't be able to help. – bela83 Sep 09 '20 at 10:15
  • @bela83 Which version do you have? If I type pdfjam or pdf180 I get pdfjam: This is pdfjam version 2.08. – luchonacho Sep 09 '20 at 15:20
  • OK I get it! I have version 3.03 and some wrapper scripts were removed from the pdfjam package at version 3.02: https://github.com/DavidFirth/pdfjam#-wrapper-scripts-no-longer-included-here – bela83 Sep 10 '20 at 14:27
  • @bela83 Interesting. I need to update my Ubuntu urgently! (16.04). I updated the post with the indirect command that does the same. – luchonacho Sep 11 '20 at 10:49

3 Answers3

4

For anybody who's not tied to pdfjam, you can do this with QPDF as well:

qpdf in.pdf out.pdf --rotate=+180:1-z:odd

See QPDF's documentation for more.

2

If I were in your shoes I'd split the document in as many files as the pages, rotate only odd ones, and merge all the pages back together.

Daniele
  • 448
1

Using pipe with pdfjam can do the task. Rotate some pages and write to stdout. Then, throw pipe, read other pages from original file merged with the rotated pages from stdin.

For example, the code below rotates some pages to generate a PDF booklet with 2x2 pages per sheet side, double sided (file.pdf contains 8 pages):

pdfjam file.pdf '5,4,7,2' --no-landscape --angle 180 -o /dev/stdout | pdfjam file.pdf '8,1' /dev/stdin '1,2' file.pdf '6,3' /dev/stdin '3,4' --no-landscape --nup 2x2 -o out.pdf
AdminBee
  • 22,803