Since you found out already...
* ...how to separate multipage PDF documents into singlepage files, and
* ...how to re-combine multiple PDF documents into a single one
using Ghostscript, here is how to rotate pages. However, this does not work reliably, because it depends on Ghostscript's ability to discover the main flow of text orientation on each page:
* -dAutoRotatePages=/None
-- retains orientation of each page;
* -dAutoRotatePages=/All
-- rotates all pages (or none) depending on a kind of "majority decision";
* -dAutoRotatePages=/PageByPage
-- auto-rotates pages individually.
Add one of these to the Ghostscript commandline you're using.
If there is no text on a page (or if there is an automatic page rotation set to /None
), then Ghostscript uses the setpagedevice
settings. You can pass such setpagedevice
parameters on the Ghostscript commandline using the -c
switch like this:
* -c "<</Orientation 3>> setpagedevice"
-- sets landscape orientation;
* -c "<</Orientation 0>> setpagedevice"
-- sets portrait orientation;
* -c "<</Orientation 2>> setpagedevice"
-- sets upside down orientation;
* -c "<</Orientation 1>> setpagedevice"
-- sets seascape orientation.
Probably you need to set the orientation for each page when extracting the pages. I don't think it would work when merging them back to the unified document (I have never tested this).
However, I'd also recommend to you that you have a look at pdftk
(which is also available for Windows). It is a commandline tool that can extract pages from PDFs, merge multiple PDF files, rotate pages, and much more. Easier to use than Ghostscript for your stated purposes, and much faster as well. See here for details: http://www.accesspdf.com/pdftk/ .