[gs-devel] rotating pages in a document to portrait
Ray Johnston
Ray.Johnston at Artifex.com
Tue May 20 10:05:36 PDT 2008
Hi Lee,
The '-dAutoRotatePages' option is only relevant to the 'pdfwrite' device (it
is described in Ps2pdf.htm). This is an Adobe distillerparam parameter and
is ignored by Ghostscript in general.
Ghostscript follows the PLRM (Adobe's PostScript Language Reference Manual
3rd edition), and the only 'suto-rotation' is provided by the
'setpagedevice'
implementation which will rotate _IF NEEDED_ to find a match between the
requested PageSize and those available in the various 'slots' in the
'InputAttributes' dictionary.
Ghostscript implements an extended form of the 'setpagedevice'
InputAttributes
parameters to support variable page sizes. This is set up in the
lib/gs_setpd.ps
file with the entry:
mark /PageSize [0 dup 16#7ffff dup] .dicttomark
which allows support of page widths and lengths up to 524287 points (up to
29127 inches). This is done intentionally to allow 'raster' format devices
to accept arbitrary page sizes/shapes.
Ghostscript also populates the InputAttributes dictionary with a LARGE
variety
of page sizes. This is done in lib/gs_setpd.ps by:
statusdict /.pagetypenames get {
counttomark 1 sub 2 idiv exch mark exch /PageSize exch
% stack: mark --dict-- --dict-- ... key mark /PageSize pagetypename
% see note above about pagetype executable array contents.
load dup 0 get exch 1 get 2 array astore .dicttomark
} forall
If you want to support only a single page size, then remove or comment out
this latter section of PostScript code.
Then if all you have is a 'letter' size, and the request comes in for
PageSize [792 612] (landscape) Ghostscript will rotate.
If you wish to support a range of lengths, but limited width, then change
the 'range' to specify the maximum width and length you wish to support
(values in points == 1/72 inch). For example to support up to 8.5 inches
wide
and 24 inch long faxes, use:
mark /PageSize [ 0 0 612 1728 ] .dicttomark
To support only up to 'legal' length (14 inches) use:
mark /PageSize [ 0 0 612 1008 ] .dicttomark
When Ghostscript gets a request for a page size that is wider than the 612
points (8.5 inches) it will rotate it automatically, setting the length of
the TIFF image to the requested width.
Note that Ghostscript (or any conforming PostScript setpagedevice
implementation)
will also perform scaling of the page to 'best fit' and 'center' as
described
in the 'Policies' section of Adobe's PLRM.
Regards,
Ray Johnston
------------------------------------------------------------------------
//
Lee Howard wrote:
> I occasionally encounter documents (both Postscript and PDF, but
> usually they're PDF that have this "feature") where some pages are
> oriented portrait and some are oriented landscape.
>
> For faxing all pages need to be oriented portrait. How can I cause
> the output to be consistently done in portrait when the input document
> has a mix of portrait and landscape pages?
>
> Typically this is the conversion process to produce the fax images:
>
> gs -q -sDEVICE=tiffg4 -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter
> -dFIXEDMEDIA -dBATCH -r203.29x98 -sOutputFile=out.tif in.pdf
>
> However, the -dFIXEDMEDIA causes the landscape-oriented images to be
> chopped off on their right. So we can do this:
>
> gs -q -sDEVICE=tiffg4 -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter
> -dPDFFitPage -dBATCH -r203.29x98 -sOutputFile=out.tif in.pdf
>
> And this prevents the chopping from occurring, but the page is still
> not well-fitted to the page in that there's now a lot of white space
> at the top.
>
> -dAutoRotatePages=/PageByPage doesn't seem to do anything in this case.
>
> Any suggestions would be appreciated.
>
> Thanks,
>
> Lee.
> _______________________________________________
> gs-devel mailing list
> gs-devel at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/gs-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ghostscript.com/pipermail/gs-devel/attachments/20080520/81464ea9/attachment.htm
More information about the gs-devel
mailing list