Simple accounting filter/backend (With Perl or another script language)

Helge Blischke H.Blischke at srz-berlin.de
Fri Jun 18 04:54:38 PDT 2004


Nayco wrote:
> 
> Helge Blischke wrote:
> > Anonymous wrote:
> 
> > Instead of a lengthy explanation, here is an example:
> [...]
> > %%BoundingBox: 10 187 31 774
> > %%HiResBoundingBox: 10.278000 187.073994 30.077999 773.981976
> > %%BoundingBox: 10 391 30 738
> > %%HiResBoundingBox: 10.278000 391.085988 29.339999 737.981977
> [...]
> > You see, for every page in the job (sample.ps has 2 pages and is _not_
> > DSC compliant), this
> > command lists the bounding box in standard and hi res form.
> 
> Ok... So what you say is that my account backend can call gs that way, then parse the output to determine the number of pages processed ?
> Will it work for *every* job sent to the printer ? I mean, is there always postscript at the backend level, regardless of the original contents (Provided that the printer is postscript-compliant) ?
> 
> If so, what is left is to find how to call those ^@\`#¹ backends while sending them the DEVICE_URI in ARGV[0].... :-\
> 
> Thanks a lot.
> 
> PS: I saw that Pykota uses the "%%Pages: " ps tags to count pages... I implemented it, it works fine, but is it always accurate ? Is it better than the bbox method ?

Yes, the bbox message will work for _every_ PostScript job.
The easiest (and natural) way to call a filter like this is to list in
as a cupsFilter: "..."
in the printer's PPD. For printers that use fancy things like
foomatic_rip or hpijs, you'd
have to list this accounting filter prior to the filters that convert
PostScript to the specific
printer code.

If you use this approach, you don't need to wrap the existing backends
(some rely on getting
the device URI in argv[0] which isn't easy to perform when using script
languages).

And no, the PyKota method relies on the PostScript job being DSC
compliant - at least with
repect to the "%%Page: ..." comments, whereas the bbox method even works
with PostScript jobs
that contain no comments at all, moreover, it even works with binary
PostScript.

Helge

-- 
H.Blischke at srz-berlin.de
H.Blischke at srz-berlin.com
H.Blischke at acm.org




More information about the cups-devel mailing list