Page Counting Postscript.... ------------------------------------------------------------------------------- You must ask the printer. EG: How many pages did the user print AFTER they have finished printing. If they go over the print quote, no more printing. It is impossible to always determine the number of pages a postscript program will print because postscript is a proper computer language. EG: Create a postscript program to print a random number of pages. In this case the page counting program will almost certainly have a different page count than the actual number of pages printed. For more information see print quota method we developed... https://antofthy.gitlab.io/info/postscript/printer_quota.txt ------------------------------------------------------------------------------- Tell printer to print only upto so many pages. WARNING -- this would require heavy postscript knowledge -- WARNING Install a showpage replacement (and any other page outputer) Tell printer how many pages this user can print send job to printer printer returns the number of pages user used to controller to update page limit for next print job. This would require a good communcation program and a heavy programming effort for the showpage replacement code, which can't be circumvented. ------------------------------------------------------------------------------- Using Ghostscript, or other PS interperter. #!/bin/sh # # pagecount [postscript_file...] # ( cat $* echo currentdevice /PageCount gsgetdeviceprop == flush ) | gs -q -sDEVICE=bit -sOutputFile=/dev/null -r5 - | tail -1 This method works well for almost ALL postscript programs, however it takes time to do page counting as it is CPU intensive, even without the ghostscript graphics display. In the mean time unless some sort of print queue pipeline is used the printer is NOT printing while page counting is being performed. It is also simple for a postscript program to see if it is running on the printer or under a interperter like ghostscript and then LIE! That is as postscript is a programming language it could abort early if running under ghostscript producing either only one page or no pages at all! On a real printer the same program could output the whole document. A random page outputing program also fools such a system. EG: print 3 pages one time, 5 pages another. ------------------------------------------------------------------------------- comp.lang.postscript FAQ 1.2 This is what is used by Novel Servers... For DSC compliant postscript files -- grep -c %%Page: document.ps Note all postscript programs follow DSC conventions. Indeed the DSC stuff are just comments and could be very simplely striped from a print job before sending. Also what do you do when you recieve a non-DSC postscript complient document? Reject it? -------------------------------------------------------------------------------