[gs-devel] rotating pages

Ray Johnston Ray.Johnston at Artifex.com
Mon Feb 23 10:20:24 PST 2009


Hello Klaus,

I don't know why I missed this original posting. Sorry.

Ghostscript is a functional Level 3 PS interpreter, and as such it
includes the features of 'setpagedevice' that provide auto-rotation.
The way this works is that if you only have a single 'slot' in the
'InputAttributes' dictionary describing a single page size (I assume
this would be 'letter' or 'A4' depending on your country's preferred
page size), then Ghostscript will rotate pages to fit the page.

Also, depending on the value of the /PageSize entry in the /Policies
dictionary of the pagedevice, then Ghostscript will perform scaling
of the data to fit the page. The values for the policies are in the
PostScript Language reference manual. The two that are probably the
most interesting are:

  3   Select the nearest available medium and adjust the page to fit,
      as described in "Recovery Policies and Media Selection."

  4   Select the next larger available medium and adjust the page to
      fit.

If there is only a single page size available, then they are both
effectively the same.

When setting the InputAttributes dictionary, a technique must be used
that explicitly removes the unwanted page sizes, otherwise only a
single slot will be modified or added. A PS sequence that will set
up a single page size, and set the Policy to 3 is as follows:

%!PS
  %   Sequence to set up for a single page size, auto fit all pages.
  << /Policies << /PageSize 3 >>
     /InputAttributes currentpagedevice /InputAttributes get    % 
current dict
     dup { pop 1 index exch undef } forall    % remove all page sizes
     dup 0 << /PageSize [ 612 792 ] >> put    % for A4 use [ 595 842 ]
  >> setpagedevice
%---------------------------------------------------------------------

I hope this helps you do what you want. As Ken said, the 'Install'
procedure can be used to further modify the position on the page
and the 'ViewerPreProcess' procedure can modify things even more
"invasively", but you probably can get by with the standard PostScript
above.

Best Regards,
Ray Johnston
------------------------------------------------------------------------







Ken Sharp wrote:
> Hi Klaus,
>
> At 20:04 17/02/2009 +0100, Klaus Darilion wrote:
>
>> landscape format. The problem is, that fax only supports portrait 
>> (landscape can be shrunk to avoid clipping).
>
> [snip]
>
>
>> So what we need would be an option for ghostscript to rotate all 
>> pages to portrait - regardless of the original orientation of 
>> /Rotation values.
>>
>> Thus, is this possible? Is there such an option?
>
> As such, no. However....
>
> Ghostscript is a PostScript device, and PostScript is a programming 
> language, you can alter the behaviour of the interpreter by writing 
> PostScript programs. In particular you can redefine the behaviour of 
> setpagedevice.
>
> In one example you could store the requested page size whenever it 
> changes, and write a custom /BeginPage procedure which would rotate 
> the page if it is landscape (or simply always rotate the page if 
> required, but this could have side effects, multiple definitions of 
> the page size would result in multiple rotations...).
>
>
>> Further, I found some examples using -dAutoRotate= but I could not a 
>> manual which describes the meaning of these token and the possible 
>> values. Where can I find it?
>
> The auto rotate feature is described in the ps2pdf documentation 
> (gs/doc/ps2pdf.htm) but this won't do what you require. A closer fit 
> is described in ps2ps2.htm (gs/doc/ps2ps2.htm), Section 6 'Controlling 
> the printer behavious', especially the FitPages switch.
>
> To use either of these, however, would be a 2 pass process; first 
> convert the PDF to either a new PDF or a PostScript file, then render 
> the new file and send it to the fax device.
>
>
>
>                 Ken
>
> _______________________________________________
> 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/20090223/69d6e922/attachment.htm


More information about the gs-devel mailing list