Send printer command on final PAGE_SETUP only?

Actually, I also need to send a printer command at job setup. This is easy enough though.

The thing that seems to be impossible is determining whether the current page is the last page. The GDI print architecture seems designed to be ambivalent towards page number. Generally, printing through GDI goes:

  1. Start doc
  2. Start page
  3. Send page
  4. Start page
  5. Send page
  6. Start page
  7. Send page
  8. End doc

Not exactly accurate, but you get the idea. This probably makes sense in every scenario but mine. In the last Start page (6), I need to send a command. This gets tricky because I cannot send this command during the other Start pages - it has negative consequences. I need to send this command on the final page of a print job.

DrvStartPage receives a SURFOBJ, but this does not appear to have information about the page number or the number of pages in a job. I’ve tried using the spooler’s GetJob along with the dwJobId I receive in DrvStartDoc. This path seemed to be leading to a dead end, but perhaps I didn’t follow it far enough. I don’t know.

Any printer driver experts out that who can help me determine whether the current page is the last page in a job?