[cups.development] Re: Simple accounting filter/backend (With Perl or another script language)
Jerome Alet
alet at librelogiciel.com
Tue Oct 26 13:57:05 PDT 2004
On Tue, Oct 26, 2004 at 07:27:25PM +0000, Nayco wrote:
>
> By the way, I've posted my script on
> http://nayco.free.fr/wiki/doku.php?id=comptage : I'll love feedback
here's some feedback then :
the "ghostscript + bbox" way of couting pages in binary postscript
documents, which I think was posted to this mailing list by
Helge Blischke doesn't work as expected.
It works "most of the time", but unfortunately can't correctly
handle the number of copies if this number is set inside the
PostScript code, which is the case with some drivers and/or some
applications (mozilla + kprinter, IIRC)
I'd suggest that you code a "workaround" for this problem, by
analyzing the document in two passes. I've seen two different ways
to set the number of copies in the PS code, both of which are
ignored (unless I'm completely wrong) by the bbox "hack", but this
is highly probable that some drivers output different code, and even
more probable that some student will just fool you (and me) by doing
this in a completely different way.
My own "workaround", which I'm sure is incomplete, consists of
extracting the number of copies from two different types of lines,
using the two following strings :
"%%BeginNonPPDFeature: NumCopies "
and :
"1 dict dup /NumCopies "
the lines in the PS document which contain the above code snippet
(depending on driver and/or application) set the number of copies,
you have to analyze the line to extract it, and then multiply by the
number of pages returned by the "bbox" method.
a better analysis would be to know the number of copies for each
page, but to simplify lets use the maximum number of copies ever set
in the document as the multiplier, this way we lessen (only a bit)
the chance to be cheated.
of course if none of the lines above is present in your PS document,
just assume a single copy is wanted, and hope to NOT be cheated ;-)
any comment ?
bye
Jerome Alet
More information about the cups-devel
mailing list