[cups.development] Re: Simple accounting filter/backend (With Perl or another script language)

Helge Blischke H.Blischke at srz-berlin.de
Wed Oct 27 06:28:35 PDT 2004


Jerome Alet wrote:
> 
> 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

Yes, Ghostscript ignores the copies attribute. But you may easily
intercept it
using a small prologue file fed into gs just before the file in
question.
This prolog simply could intercept the setpagedevice operator and look
for the
/NumCopies key in the operator's param dictionary.
Well, to get the old and deprecated use of the /#copies value in
userdict, 
ask for this in a /BeginPage procedure which needs only be called once.

Helge

-- 
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de
tel: +49 30 75301-360




More information about the cups-devel mailing list