Determining print status when using PrintToPrinter()

I have some rather lengthy reports that are being sent to the printer using the PrintToPrinter() method.  Since the reports can take a while to print, is there anyway to determine which page is currently printing and the total number of pages in order to give the user some feedback?  An example would be:

 Now printing page X of Y

 
niger007Asked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
As far as I know there is no way to gather that information unless the printer driver sends it back.

mlmcc
0
 
niger007Author Commented:
Ok fine.. Point noted.
0
 
TwisteddkConnect With a Mentor Commented:
From a "printer" perspective, the printer CAN tell you how many pages it's printed from it's current task, BUT in order to determine the "x of y", you'll need specific information about how many pages are being printed.
Ok, this is going to look ugly, because I pretty much suck at .NET programming. BUT.... Bear with me on this:

The "correct" (read always working, but also lways frustrating) way to do it, would be for you to send each page to the printer and then "only" count up a page when it's been SENT to the printer, not when the printer has finished printing it. this is also the "microsoft" way.. so I'd assume that this is the only "supported" method.
HOWEVER.... I'd ASSUME that you can query the win32 API from .NET, so you SHOULD be able to access the GetJob function (This is available to VB calling the Windows API, so presumably a similar function or method must exist in .NET). The GetJob SHOULD have a "pages printed" information. Again... This MAY only be the information from the driver, and as such would be totally unusable if the printer isn't a GDI printer.
However, in THEORY you can query the printer directly for the same information. This is ofcourse just not as easy, as each printer needs to be accessed differently from another, which would make your program a nightmare to create.
0
All Courses

From novice to tech pro — start learning today.