Article View: comp.lang.postscript
Article #5252Re: Counting pages to be used by PostScript document
From: Rich Berlin
Date: Wed, 03 Apr 1991 21:37
Date: Wed, 03 Apr 1991 21:37
63 lines
2773 bytes
2773 bytes
In article <1991Apr3.012910.14781@dcs.glasgow.ac.uk>, inei@dcs.glasgow.ac.uk (Nick Nei) writes:
|> This question has probably been asked before, but I am not a regular
|> reader of this group.
|>
|> "Is it possible to count the number of pages BEFORE a postscript file
|> is printed?"
|>
|> I know I can count AFTER the file is printed if I am using a LaserWriter.
|> But I am using the Sparc printer and the command:
|>
|> statusdict begin pagecount (*) print ==
|>
|> makes NeWSPrint tell porkie pies. It always says printed 1 page!
|>
|> (Please reply by e-mail if possible.)
|> --
|> Mail: Nick Nei, Computing Science Dept.,
|> Glasgow Univ., 17 Lilybank Gardens,
|> Glasgow G12 8QQ, UK. Tel: (041) 339 8855 x 5457
|> ARPA: inei%uk.ac.glasgow.dcs@nsfnet-relay.ac.uk USENET: inei@cs.glasgow.uucp
Sorry, there is no reliable way to count the pages that a job will
print without executing the PostScript. If you have a PostScript
interpreter handy, you could try something like
%!
3 dict begin
/_numpages 0 def
/showpage {/_numpages _numpages #copies add store} bind def
/copypage /showpage load def
nulldevice
userdict begin
(your-filename-here) run
end
end
_numpages print
----
Many printers don't keep a record of how many pages they've printed.
There is no GENERAL way to get page counts, either before OR after the
document is printed, because there's no guarantee that statusdict
exists, or that it implements pagecount. From the PostScript Language
Reference Manual, Second Edition, page 526:
statusdict contains product-dependent operators and other data
whose names and values vary from product to product, and sometimes
from one version of a product to another.
...
statusdict is not necessarily defined in all products. Any
reference to statusdict in a POSTSCRIPT language program impairs
the portability of that program.
If the particular engine maintains a pagecount in hardware, and
there's a way to query that value across the wire, pagecount could
probably be implemented for that printer. I'll check on whether it's
possible for the SPARCprinter.
-- Rich
Technical Details
Message-ID:
<10993@exodus.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!convex!texsun!newstop!jethro!exodus!birdland!rberlinReferences:
<1991Apr3.012910.14781@dcs.glasgow.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!convex!texsun!newstop!jethro!exodus!birdland!rberlin From: rberlin@birdlandEng.Sun.COM (Rich Berlin) Newsgroups: comp.lang.postscript Subject: Re: Counting pages to be used by PostScript document Message-ID: <10993@exodus.Eng.Sun.COM> Date: 3 Apr 91 21:37:57 GMT References: <1991Apr3.012910.14781@dcs.glasgow.ac.uk> Sender: news@exodus.Eng.Sun.COM Reply-To: rberlin@Eng.Sun.COM Organization: Sun Microsystems Lines: 63