Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Checking whether the report is still printing or not and handling printing errors

edited February 2004 in End User
Hi,
How can I check whether the report is still printing or not after call to
the Print method?
The problem is that I need to print several reports in cycle: one after
another, but only one at a time. To do this I need to know whether the
printer is still busy with my previous report before sending the next one. I
also need to respond on any errors in the printing process that might occur
there. So how do I catch errors that might have happened in the printing
process?

Thank you,
MB.

Comments

  • edited February 2004

    ReportBuilder and other Windows applications never wait for the printer to
    actually print the pages, instead the rendered pages are stored in the
    print queue as part of a Windows print job.

    ReportBuilder uses Windows API functions to print. This involves starting
    and ending a print job. Print jobs are queued by the Windows print queue.
    To see this in actiaion, access the Windows Printer Panel and select the
    print icon corresponding to your printer. Then select File | Pause Printing.
    Now run ReportBuilder reports (or other windows apps) and print multiple
    documents to your printer. You will see that nothing ever prints. Next
    double-click on the printer icon. This will display the print queued where
    you can see the print jobs are queued. Now select File | Pause Printing
    again to turn off the pause and the documents will start printing on your
    computer.

    There is a Report.OnPrintingComplete method that is called when a RB is
    finished with a print job. However, normally if you have a loop and are
    printing directly to the printer, you can just code something like this:

    Report.DeviceType := dtPrinter;
    Report.ShowPrintDialog := False;
    Report.ShowCancelDialog := False;

    Report.Print;

    ShowMessage('Report finished);


    If you want to get the status of the print jobs on the Windows printer
    queue, you will need to consult the Windows API docs.



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2004
    Guess I don't have any other choise than to dig into API documentation.
    Thank you very much for your detailed answer.
    MB.

    P.S.:I was unable to use Report.OnPrintingComplete method. The RB just seems
    to ignore the handler in this event.

  • edited February 2004

    Just tried a simple test here using RB 7.03 and the
    Report.OnPrintingComplete works properly. Try creating a new application.
    Place a TppReport on a form and a button. Implment the the
    Report.OnPrintingComplete aned ButtonClick event-handlers as shown below.


    uses
    ppTypes;

    procedure TForm1.ppReport1PrintingComplete(Sender: TObject);
    begin
    ShowMessage('report printing completed');
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ppReport1.DeviceType := dtPrinter;
    ppReport1.ShowPrintDialog := False;
    ppReport1.ShowCancelDialog := False;

    ppReport1.Print;
    end;



    This event only fires when printing to the printer. If you are loading
    reports from database or file templates, then you need to assign the
    event-handler after loading the report. Whenver you load templates the
    event-handler names saved with the template are used.


    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.