[comp.lang.postscript] selecting pages from PostScript

kenc@madmax.Viewlogic.COM (Kenstir) (01/11/91)

[sorry if this is a repost]

Is it possible for a filter to select only certain pages
from a PostScript document?  I have a huge document
(thanks, OSF/Motif) which I need to print in small chunks
so as not to offend the community at large by hogging
the printer.

Any programs out there to do this sort of thing?


----- Thanks to all who have read this far -----
Kenneth H. Cox
Viewlogic Systems, Inc.
kenc@viewlogic.com
...!harvard!cg-atla!viewlog!kenc

mzellers@starnet.uucp (Mark Zellers) (01/13/91)

In article <1991Jan10.171621@madmax.Viewlogic.COM> kenc@madmax.Viewlogic.COM (Kenstir) writes:
>
>Is it possible for a filter to select only certain pages
>from a PostScript document?  I have a huge document
>(thanks, OSF/Motif) which I need to print in small chunks
>so as not to offend the community at large by hogging
>the printer.
>
It depends entirely on whether the file you are working with is an
Encapsulated PostScript file with the appropriate %%Page comments.  If
so, it is a fairly simple matter to filter out the pages you don't want
by looking at the comments.  On the other hand, there are PostScript
programs that are unencapsulatable (?).  Consider the following
fragment:
      /tmpstr 10 string def
      /Times-Roman findfont 300 scalefont setfont
      0 1 9 {tmpstr cvs 100 100 moveto show showpage} for

The last line produces 9 pages of output, so to only output pages 4-6
you would actually have to modify the program.

Mark H. Zellers
decwrl.dec.com!voltaire!bwayne!mark

clewis@ecicrl.UUCP (Chris Lewis) (01/14/91)

In article <1991Jan12.194650.25292@starnet.uucp> mzellers@starnet.UUCP (Mark Zellers) writes:
>In article <1991Jan10.171621@madmax.Viewlogic.COM> kenc@madmax.Viewlogic.COM (Kenstir) writes:

>>Is it possible for a filter to select only certain pages
>>from a PostScript document?  I have a huge document
>>(thanks, OSF/Motif) which I need to print in small chunks
>>so as not to offend the community at large by hogging
>>the printer.

>It depends entirely on whether the file you are working with is an
>Encapsulated PostScript file with the appropriate %%Page comments.  If

Slight mistake Mark, you meant "conformant with the document structuring
conventions postscript file".  EPS files are files for pictures for enclusion
in other documents, and hence don't have multiple pages - they're essentially
includable images.

psxlate in the psroff distribution can be modified quite simply to handle
this for conformant documents.
-- 
Chris Lewis, Phone: (613) 832-0541
UUCP: uunet!utai!lsuc!ecicrl!clewis
Moderator of the Ferret Mailing List (ferret-request@eci386)
Psroff mailing list (psroff-request@eci386)

raja@bombay.cps.msu.edu (Narayan S. Raja) (01/17/91)

In article <1091@ecicrl.UUCP>, (Chris Lewis) writes:
< In article <1991Jan12.194650.25292@starnet> (Mark Zellers) writes:
< >In article <1991Jan10.171621@madmax> (Kenstir) writes:

< >>Is it possible for a filter to select only certain pages
< >>from a PostScript document?  I have a huge document
< >>(thanks, OSF/Motif) which I need to print in small chunks
< >>so as not to offend the community at large by hogging
< >>the printer.
< 
< >It depends entirely on whether the file you are working with is an
< >Encapsulated PostScript file with the appropriate %%Page comments.  If
< 
< Slight mistake Mark, you meant "conformant with the document structuring
< conventions postscript file".  EPS files are files for pictures for enclusion
< in other documents, and hence don't have multiple pages - they're essentially
< includable images.
< 
< psxlate in the psroff distribution can be modified quite simply to handle
< this for conformant documents.


In fact, if you have the `Transcript' filters
(which you probably do), you can do it quite 
simply using psrev:

  "psrev -s 23,65-69,81 file.ps | lpr"

will print pages 23,65-69, and 81 on your
default printer.  Check the psrev man page.

This will work with conformant documents.

If your document was produced by dvi2ps/dvips
you're out of luck.  However if you feel like
some PostScript hacking you can put

   %!PS-Adobe-1.0

at the top of your PostScript document, and

   %%Trailer

at the end.  Now psrev will at least not reject
the document.  PostScript hacking is required.


Narayan Sriranga Raja.

decouty@irisa.fr (Bertrand Decouty) (01/17/91)

In article <1991Jan17.082652.24288@msuinfo.cl.msu.edu> raja@cpswh.cps.msu.edu writes:
| 
| In article <1091@ecicrl.UUCP>, (Chris Lewis) writes:
| < In article <1991Jan12.194650.25292@starnet> (Mark Zellers) writes:
| < >In article <1991Jan10.171621@madmax> (Kenstir) writes:
| 
| < >>Is it possible for a filter to select only certain pages
| < >>from a PostScript document?  I have a huge document
| < >>(thanks, OSF/Motif) which I need to print in small chunks
| < >>so as not to offend the community at large by hogging
| < >>the printer.
| < 
[......]
| 
| 
| In fact, if you have the `Transcript' filters
| (which you probably do), you can do it quite 
| simply using psrev:
| 
|   "psrev -s 23,65-69,81 file.ps | lpr"
| 
| will print pages 23,65-69, and 81 on your
| default printer.  Check the psrev man page.
[....]
| 
| 
| Narayan Sriranga Raja.


I think you are speaking about printing motif manual ps document. We have
been faced recently to the same trouble. It is a huge file (around 15
MBytes), made with (di?)troff and so no epsf (begins with %! only). More,
it includes a lot of figures, each figure being an included epsf file with
%%Page: comment.

I have tried psrev (several versions from Transcript). No one worked because
of figures.

So i suggest you the following method, which uses sed (remember it is a 15
MB file...):
1- first locate the prologue
sed -e "1,/%%EndProlog/w prolog.ps" manual.ps >/dev/null
(from memory, in fact manual.ps is all.ps)

2- then prints selected pages:
sed -e "/Page: label 70/,/Page: label 75/w tmp" manual.ps >/dev/null
cat prolog.ps tmp |lpr
(and you print pages 70 to 75)

Notes: 
- prolog.ps MUST begin with %!
- as sed reads each time the whole file, it is rather long, but...
- do not try this method for pages <=46 because there is a page # 460!
- print few pages together because due to figures, some pages are huge:
e.g.: pages 5-11 to 5-14 are 900 KB long.
- if somebody has a better method, tell us!

Flame: IMHO, it is a shame a company like OSF can't produce a real ps file
using decent products. At least, they could have cut their man into several
parts. Don't forget many people print on laserwriter at 9600 bauds! Time to
download 15 megabytes??

Disclaimer: i speak for myself

Bertrand Decouty.

-- 
[ Bertrand DECOUTY             | EMAIL : decouty@irisa.fr, decouty@irisa.uucp  ]
[ IRISA - INRIA (Atelier)      |         {uunet,mcsun,inria}!irisa!decouty     ]
[ Campus de Beaulieu           | PHONE : +33  99 36 20 00                      ]
[ F-35042 Rennes Cedex - FRANCE| FAX : +33  99 38 38 32 | TELEX: 950473 UNIRISA]

richard@gara.une.oz.au (Richard Mackerras CCEN) (01/21/91)

From article <1991Jan17.082652.24288@msuinfo.cl.msu.edu>, by raja@bombay.cps.msu.edu (Narayan S. Raja):
> In fact, if you have the `Transcript' filters
> (which you probably do), you can do it quite 
> simply using psrev:
> 
>   "psrev -s 23,65-69,81 file.ps | lpr"
> 
> will print pages 23,65-69, and 81 on your
> default printer.  Check the psrev man page.


Where can I get psrev and the `Transcript' filters
from.  
      Ftp sites???? 
		    Which ones?


Richard Mackerras
richard@gara.une.oz.au