[comp.lang.postscript] extract odd/even pages from postscript file

ruck@reef.cis.ufl.edu (John Ruckstuhl) (04/15/91)

I would like to print some PostScript documents double-sidedly.
If there is a PostScript page-eject command, I'd guess there is a simple
awk or perl solution which can extract odd (or even) pages for me to
print.  Then of course I can restock my LaserWriter's feed tray and
print the opposite sides.
Since I know nothing of PostScript, I hoped some reader of this
newsgroup might be kind enough to provide a solution.

BTW, I do know that I can get odd/even from a dvi-file with dvi2ps.
Also, I did look for an FAQ posting, but didn't find one in this newsgroup.

Thank you,
ruck.
-- 
John R Ruckstuhl, Jr			ruck@alpha.ee.ufl.edu
Dept of Electrical Engineering		ruck@cis.ufl.edu, uflorida!ruck
University of Florida			ruck%sphere@cis.ufl.edu, sphere!ruck

gfreeman@csadfa.cs.adfa.oz.au (Graham Freeman) (04/18/91)

ruck@reef.cis.ufl.edu (John Ruckstuhl) writes:
>  
> I would like to print some PostScript documents double-sidedly.
> If there is a PostScript page-eject command, I'd guess there is a simple
> awk or perl solution which can extract odd (or even) pages for me to
> print.  Then of course I can restock my LaserWriter's feed tray and
> print the opposite sides.


I would suggest including the following PostScript at the head of
your file, to print the even numbered pages:

%!
% Even pages
/oldshowpage /showpage load def
/showpage
 {
    0 begin /PageNo PageNo 1 add def PageNo 2 mod 0 eq
    {oldshowpage}{erasepage} ifelse end
 }bind def
/showpage load 0 1 dict dup /PageNo 0 put put


and this at the head to print only the odd pages:

%!
% Odd pages
/oldshowpage /showpage load def
/showpage
 {
    0 begin /PageNo PageNo 1 add def PageNo 2 mod 0 eq
    {erasepage}{oldshowpage} ifelse end
 }bind def
/showpage load 0 1 dict dup /PageNo 0 put put


These fragments redefine the "showpage" operator to erase or show
the alternate pages.

                                     Graham Freeman

clewis@ferret.ocunix.on.ca (Chris Lewis) (04/19/91)

In article <28017@uflorida.cis.ufl.EDU> ruck@reef.cis.ufl.edu (John Ruckstuhl) writes:
>I would like to print some PostScript documents double-sidedly.
>If there is a PostScript page-eject command, I'd guess there is a simple
>awk or perl solution which can extract odd (or even) pages for me to
>print.  Then of course I can restock my LaserWriter's feed tray and
>print the opposite sides.

Psxlate from psroff 3.0 has an option to do this.  Provided that the
file conforms to the Adobe Document Structuring Convention.

Psroff 3.0 should be coming out in comp.sources.unix about now.
-- 
Chris Lewis, Phone: (613) 832-0541, Internet: clewis@ferret.ocunix.on.ca
UUCP: uunet!mitel!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request@eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!