Newsgroups: comp.lang.postscript
Path: utzoo!sq!lee
From: lee@sq.sq.com (Liam R. E. Quin)
Subject: Re: PostScript page counter?
Message-ID: <1990Aug1.214448.17881@sq.sq.com>
Organization: SoftQuad Inc.
References: <1990Jul30.181713.29483@phri.nyu.edu> <6988@helios.TAMU.EDU> <226@heaven.woodside.ca.us>
Date: Wed, 1 Aug 90 21:44:48 GMT
Lines: 46

Glenn Reid <glenn@heaven.UUCP> writes:
>I have a feeling there is a midway-point between the "you can't count
>pages without an interpreter" answer and the "just look at the %%Pages
>comment" answers [...]
and then suggests writing a simple parser to look for "showpage".

Some problems with that:
* you'd have to count copypage as well, of course
* you'd also have to take #copies into account (rather harder)
* what about
  1 NCopies 1 { copypage } repeat erasepage
  produced by applications whose programmers didn't know about #copies...?

The original poster wanted to prevent students printing large jobs,
presumably either accidentally or intentionally.  The former case can be
met in most cases by looking for %%Page and #copies.
The deliberate Blatter Of Large Documents (BOLD) can be stopped by
threatening death, or stringing up by the ankles... but not by anything
else short of interpreting enough of the file completely to determine
that it exceeds the Allowed Page Count.

For example, it is clear that Woody and Friends can produce a "cexec"
file that calls showpage from machine-code.  You couldn't do anything
about that.

And routines to hex-encode data are easily available.

Perhaps a better way would be to redefine showpage and copypage in the
printer at the start of each job to cause an error after MAX$JOB pages.
	/oldshowpage { showpage } load bind etc def
	/showpage {
	    NumberOfPages LotsAndLots gt
	    { please ignore to EOF }
	    { oldshowpage }
	    ifelse
	}

this relies on the undocumented PostScript command "please ignore to EOF"
which does exactly what it says [0.75 :-)].

Lee
-- 
Liam R. E. Quin,  lee@sq.com, {utai,utzoo}!sq!lee,  SoftQuad Inc., Toronto
``He left her a copy of his calculations [...]  Since she was a cystologist,
  she might have analysed the equations, but at the moment she was occupied
  with knitting a bootee.''  [John Boyd, Pollinators of Eden, 217]
