🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #6203

Re: "Take out" a position of a PS file

#6203
From: Graham Freeman
Date: Tue, 04 Jun 1991 04:19
42 lines
2249 bytes
luo@dutepp1.et.tudelft.nl (Jian Luo) writes:
>Sometimes I get a Postscript file which consists of many pages.  To some of the
>reasons, I need only print some of the pages.  So a utility which can "take out"
>these pages will do my work.

The way I solve this problem is to prepend the following PostScript
to my PostScript file before despatch to the printer.  It redefines
the "showpage" operator to count the occurrences of "showpage" calls,
and calls "erasepage" if the current page number is less than the
"PagLow", the starting page.  Stopping when the page number exceeds
"PagHi" is more difficult, as PostScript does not have an operator
for clean termination of execution.  "exit" would work only if the
"showpage" were not embedded in some type of loop.  I use "stop",
which may generate an error page after the requested pages, depending
on what type of error handler is installed in the machine.

This solution does not consider the page numbers within the document
itself (if they do not commence at one or are in reverse order), and
does not consider applications where "showpage" is already redefined
to give multiple pages per output page.

To use it, I edit the numbers associated with /PagHi and /PagLow
at the start, and send it ahead of the file to be printed.

                                              Graham Freeman
-------------------------Cut here-----------------------------------

%!
            % Only print pages in the selected page range
/PagLow 2 def
/PagHi 4 def

/oldshowpage /showpage load def
/showpage
 {
    0 begin /PageNo PageNo 1 add def 
    PageNo PagLow lt {erasepage}{oldshowpage}ifelse
    PageNo PagHi ge {stop} if
    end
 }bind def
/showpage load 0 1 dict dup /PageNo 0 put put
Technical Details
Message-ID: <1991Jun4.041945.4213@sserve.cc.adfa.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!manuel!sserve!csadfa!gfreeman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!manuel!sserve!csadfa!gfreeman
From: gfreeman@csadfa.cs.adfa.oz.au (Graham Freeman)
Newsgroups: comp.lang.postscript
Subject: Re: "Take out" a position of a PS file
Keywords: PostScript
Message-ID: <1991Jun4.041945.4213@sserve.cc.adfa.oz.au>
Date: 4 Jun 91 04:19:45 GMT
Sender: news@sserve.cc.adfa.oz.au
Organization: Australian Defence Force Academy, Canberra, Australia
Lines: 42