Is there any way to rotate PDF pages from the command line in in OS X?
3 Answers
Sejda's command line can help rotate PDF pages.
./bin/sejda-console rotate --rotation 90 --files /tmp/file.pdf --output /tmp --pageSelection 4,12-14
Open source project, free, I'm one of the developers.
-
1
Check out qpdf
. From the manual:
--rotate=[+|-]angle[:page-range]
Apply rotation to specified pages. The page-range portion of the option value has the same format as page ranges in Section 3.4, “Page Selection Options”. If the page range is omitted, the rotation is applied to all pages. The angle portion of the parameter may be either 90, 180, or 270. If preceded by + or -, the angle is added to or subtracted from the specified pages' original rotations. Otherwise the pages' rotations are set to the exact value. For example, the command qpdf in.pdf out.pdf --rotate=+90:2,4,6 --rotate=180:7-8 would rotate pages 2, 4, and 6 90 degrees clockwise from their original rotation and force the rotation of pages 7 through 9 to 180 degrees regardless of their original rotation, and the command qpdf in.pdf out.pdf --rotate=180 would rotate all pages by 180 degrees.
This can be achieved by using pdf90
, pdf180
or pdf270
, which are all part of pdfjam
and is convenient if you already have mactex
. Otherwise you can install it with homebrew cask, by brew cask install mactex
. To rotate the PDF document.pdf
90 degrees anticlockwise, use:
pdf90 document.pdf
This will create a file document-rotated90.pdf
. See also this answer.
UPDATE
As of 3.02 the scripts are not part of pdfjam
any more, but of the unsupported pdfjam-extras
. Use instead:
pdfjam --angle 90 --fitpaper true document.pdf
pdfjam --angle 180 document.pdf
pdfjam --angle 270 --fitpaper true document.pdf
Use the suffix option to alter the default suffix -pdfjam
, such as --suffix rotated270
.
-
1