Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!adobe!heaven!glenn From: glenn@heaven.woodside.ca.us (Glenn Reid) Newsgroups: comp.lang.postscript Subject: Re: PostScript page counter? Message-ID: <226@heaven.woodside.ca.us> Date: 31 Jul 90 01:00:14 GMT References: <1990Jul26.173633.13911@msuinfo.cl.msu.edu> <1990Jul30.153325.15342@zoo.toronto.edu> <1990Jul30.181713.29483@phri.nyu.edu> <6988@helios.TAMU.EDU> Reply-To: glenn@heaven.UUCP (Glenn Reid) Organization: Skyline Press, Woodside CA Lines: 50 In article <6988@helios.TAMU.EDU> skdutta@cs.tamu.edu (Saumen K Dutta) writes: >If you think there could be problems with the %Pages in postscript >file due no non-conformance of standards or suspecting malicious >intent you could also check up for the control character ^L in the >postscript file which is usually used for pagebreak In five years of looking at PostScript files I have never seen a control-L character embedded in a file, nor should they be. What application or system do you use such that a ^L is "usually used for pagebreak," out of curiosity? I can't say I'd recommend that technique, although I guess it can't hurt to look for ^L. 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, although I'll admit that I haven't actually tried it. In reality, almost every PostScript driver defines some procedure in the prologue the file called "EndPage" or "EP" or "SP" or whatever, and there is one invocation of that procedure for each page printed. With a moderately simple parser, it should be possible to figure out the name of the procedure that contains "showpage" in it somewhere, then go looking for instances of that procedure name in the rest of the document. Example: /BP { /page_save save def } def % begin-page /EP { page_save restore showpage } def % end-page ... BP % lots of stuff EP Any volunteers to write the simple parser? If it can recognize the basic syntax /name { { stuff } } I suspect that you could find the procedure that contained "showpage" fairly easily. Any volunteers? Want to endear yourself to the PostScript community with a great page-counting program? [ Want to earn real $$ in your spare time sharpening saw blades? ] (Glenn) cvn -- Glenn Reid PostScript/NeXT consultant glenn@heaven.woodside.ca.us Independent Software Developer ..{adobe,next}!heaven!glenn 415-851-1785