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

Determining Page Range from Print Dialog

edited October 2005 in Devices
In my application I have some PDF Attachment files that I spool to the
printer after my report.

I currently do this by using a combination of the BeforePrint,
OnPrintDialogClose, and OnCancel events to find out if the report was
printed or cancelled, and providing there was no cancel I simply call my
routine to spool these PDF's in the AfterPrint event.

The only problem is I do not want to spool these PDF's if the user is not
printing the entire report from the preview. For example, if they choose to
print only the current page, or a subset of pages I do not want my PDF's to
print.

Therefore I need some way to determine the selection of the Page Range group
in the PrintDialog. Maybe I am just missing it, but I do not see any
reference to it from the Report.PrintDialog object.

Where can I get this value from?

Thanks,

Jeff Guidotti
(Delphi 5/ReportBuilder v7.03)

Comments

  • edited October 2005
    Hi Jeff,

    There is no reference to the actual page range in the TppPrintDialog class,
    however there are two options to gain access to this information.

    1. Create a custom print dialog that exposes this value. See the article
    below on replacing the dialogs in ReportBuilder.

    2. The edtPageRange EditBox is a published property and can be accessed by
    typecasting the Report.PrintDialog property as TppPrintDialog. Then you can
    send the text from this edit box to the ppTextToPageList procedure in the
    ppUtils.pas file to get a valid page list if you would like. See the
    TppPrintDialog.btnOKClick procedure for how this is done in RB.

    ------------------------------------------------------------
    Tech Tip: Replacing Built-in Dialogs/Forms in ReportBuilder
    ------------------------------------------------------------

    ReportBuilder has an open architecture for replacing any of the built-in
    dialogs. You can replace any of the built-in dialogs by creating a new form
    that inherits from an abstract ancestor and then registering it as the new
    built-in dialog.

    For example to replace ReportBuilder's print dialog you could

    1. Create a new Print dialog by renaming ReportBuilder's default print
    dialog, then doing a SaveAs to save it under another unit name.

    The default dialog resides in RBuilder\Source\ppPDlg.pas and the form is
    called ppPrintDialog. You should assign your form a unique name, for
    example, myPrintDlg, and save the unit to another name. Also save the unit
    to the directory where your other forms are stored (not RBuilder\Source).

    2. Make desired changes.

    You will notice that the print dialog inherits from an ancestor
    TppCustomPrintDialog - this ancestor resides in ppForms.pas (where all the
    abstract ancestor forms for ReportBuilder are defined).

    3. Register the new form.

    Declare an initializtion section at the bottom of the unit:

    initialization

    ppRegisterForm(TppCustomPrintDialog, TMyPrintDialog);


    4. Add the new unit to your project and compile.

    Now your preview dialog should be automatically created and destroyed by
    ReportBuilder. The two page preview dialog in the
    RBuilder\Demos\Reports\Demo.dpro was created this same way. The only
    difference is the ppRegisterForm call is in then OnClick event of the
    button.


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.