Re: PostScript to PDF and Duplex/Tumble

Ken Sharp <[email protected]> Mon, 06 Jun 2016 09:53:41 +0100
Newsgroups gmane.comp.printing.ghostscript.devel
Message-ID <[email protected]>
Hi Philippe,

Sorry you've had to wait for a reply, we've had a company staff meeting and 
so we've all been away from our desks.


At 17:02 01/06/2016 +0000, RITTER, Philippe wrote:

>I'm using Ghostscript for converting a Postscript generated file to PDF. 
>It is working fine, except if in the postscript file there is this command :
><</Duplex true
>/Tumble true
>/EndOfSet false
> >>setpagedevice
>
>The Tumble is not recognized. I think it is maybe by design, because 
>Duplex is not possible in PDF.

None of those requests will have any effect with the pdfwrite device. 
Device-specific requests are ignored by devices which don't implement them; 
since Tumble is only relevant with Duplex, any device which does not 
implement Duplex will also not implement Tumble.

Because the PDF specification doesn't allow for print features like these, 
they cannot be embedded in the PDF file and so the pdfwrite device does 
indeed ignore them.


>  But as my document is full duplex, and printed on a Canon Inkjet system, 
> I want that in my PDF some pages are turned 180° for printing like Duplex 
> Tumbled.

Can you not simply specify Duplex and Tumble when you print the PDF file to 
your printer ?


>I have also tried to put /orientation 2, but it doesn't work either.

All the entries in the page device dictionary are *requests*, which a 
device may honour or ignore as it appropriate. Note that the correct key 
should be /Orientation, not /orientation, PostScript is case-sensitive.


>Can someone help me or give me some information how I could achieve this ? 
>Maybe in the Postscript file directly, or in command line in gs ?

You can rotate the pages if you really want to do so by providing a 
BeginPage procedure which does what you want. This procedure is called at 
the start of every page and is permitted to do operations that affect the 
CTM after the page is established but before the program is executed.

This code:

<<
/BeginPage
{               %% starts with number of showpages so far on the stack
   2 mod 0 eq    %% if <page> mod 2 is 0 then its an even page
   {             %% so we rotate it
     currentpagedevice /PageSize get
     aload pop -1 mul
     translate
     180 rotate
   } if
}
 >> setpagedevice

Will rotate even numbered pages by 180 degrees.


                 Regards,


                     Ken Sharp