Determining print status when using PrintToPrinter()

Posted on 2007-08-04
Last Modified: 2013-11-26
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

Question by:niger007
    LVL 100

    Accepted Solution

    As far as I know there is no way to gather that information unless the printer driver sends it back.


    Author Comment

    Ok fine.. Point noted.
    LVL 6

    Assisted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Causes of paper jams:The following are the main causes of paper jams. Guides:If the guides for the paper are not set correctly they may cause the paper to enter at an angle. You should ensure that the guides are set correctly for the paper type a…
    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now