Article View: comp.lang.postscript
Article #3576Re: page counting
From: Ross Smith
Date: Wed, 07 Nov 1990 05:52
Date: Wed, 07 Nov 1990 05:52
44 lines
1677 bytes
1677 bytes
In article <21456@well.sf.ca.us>, shiva@well.sf.ca.us (Kenneth Porter) writes:
>
>
> This subject comes up a lot and should be considered for the
> FAQ list. Perhaps pages can be accurately counted if you can
> figure out how to read the engine's page counter. This is the
> counter that shows up on the start page along with the ROM
> version and comm parameters. Perhaps it's in statusdict or
> printerdict.
>
> Ken (shiva@well.sf.ca.us)
The "pagecount" operator is defined in the Red Book. But this
operator only counts the pages "after the fact".
I wrote the following program to count the number of pages in a
PostScript file. It seems to work fine with the files I threw at
it. I hope this helps.
%!
% pagecnt.ps
% determine number of pages in a PostScript file
/_saveobj save def
/_pages 0 def
/_showpage /showpage load def
/showpage {
/_pages _pages #copies add def
} def
/copypage /showpage load def
(filename.ps) run % or include the file itself if your interpreter
% doesn't support the "run" operator
/Courier findfont 12 scalefont setfont
72 72 moveto
_pages 10 string cvs show
( total pages) show
_showpage
_saveobj restore
%%EOF
--
Ross Smith rsmith@well.sf.ca.us {apple,pacbell,hplabs,ucbvax}!well!rsmith
Technical Details
Message-ID:
<21513@well.sf.ca.us>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!well!rsmithReferences:
<THEWALT.90Oct19095522@canuck.ce.berkeley.edu> <21456@well.sf.ca.us>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!well!rsmith From: rsmith@well.sf.ca.us (Ross Smith) Newsgroups: comp.lang.postscript Subject: Re: page counting Message-ID: <21513@well.sf.ca.us> Date: 7 Nov 90 05:52:26 GMT References: <THEWALT.90Oct19095522@canuck.ce.berkeley.edu> <21456@well.sf.ca.us> Distribution: comp Lines: 44