-1

Currently it will show N/A as number of pages in the windows spool queue, is this possible to show the number of pages and what page is printing with bi-directional support on? with this file format? surely the printer itself must know what page is printing/how many pages have printed. thanks.

user3725395
  • 145
  • 2
  • 13

1 Answers1

0

I can only answer the PostScript part of this question, not the Windows spool queue. I don't know how you are inserting the PostScript into the spool queue, but assuming you are printing from an application then my very hazy memory suggests that it's the application which declares the number of pages in the job.

The printer doesn't know how many pages a PostScript program contains. In fact, in the most general case, it's not possible to determine how many times a PostScript program will execute the showpage operator. That's because PostScript is a programming language and the program might execute differently on different interpreters, or under different conditions. It might print an extra page on Tuesdays for example.

Or to take an admittedly silly example:

%!

0 1 rand {
  showpage
} for

That should print a random number of empty pages.

There are conventions which can indicate how many pages a PostScript program is expected to execute, the Document Structuring Convention contains comments which tell a PostScript processor (not a PostScript interpreter, which ignores comments, a processor treats the PostScript as just data and doesn't execute it) how many pages it has, amongst other data such as the requested media size, fonts, etc.

Not all PostScript programs contain this information and it can sometimes be awkward to extract (the 'atend' value is particularly annoying forcing the processor to read to the end of the file to find the value). Additionally people have been know to treat PostScript programs like Lego bricks and just concatenate them together, which makes the comments at the start untrustworthy. This is especially true if the first program has %% Pages: (atend)

Most printers do execute a job server loop, which means that it is possible for them to track which page they are executing, even if they don't know how many pages there will be.

It's also certainly true that a PostScript program running on a printer with a bi-directional interface could send information back to the print spooler, but there's no guarantee that a printer has a bi-directional communication interface, and there's no standard that I know of for the printer to follow when sending such information back to the computer. What should it send ? Will it be the same for Windows as Mac ?

halfer
  • 19,824
  • 17
  • 99
  • 186
KenS
  • 30,202
  • 3
  • 34
  • 51
  • yeah sure, the software knows the page count from %% Pages: as you suggest, the printer does have bi-directional support. but I can't think how I can get what page the printer is at when printing like it does with normal prints (not raw). I have tried telnet into the ip of the printer which gives the status but nothing on what it's printing and at what page it is at in the file. – user3725395 Sep 22 '20 at 15:24
  • As I said, the %%Pages may not be reliable, and if you are injecting a file directly into the print spooler (instead of printing from an application) then the print spooler doesn't have any way to know what's in the file (and I don't believe it has any intelligence to look and determine the number of pages. Non-PostScript spool files may lack any kind of information about that). If the printer sends data on stdout, then you can arrange for an EndPage procedure to write the current page on stdout, but I've no idea whether that would get to you, nor what you would do with it. – KenS Sep 22 '20 at 18:05