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

Suppress printer setup dialog pop up on the reports after the first one...

edited June 2003 in End User
Hi,
I would like to print several reports at once.
Printer Setup Dialog must be shown the for first report only and all
settings that user changes there must be used for the rest of the reports.
After printing all of the necessary reports printer settings must be set
back to initial state.
How can I accomplish this?

Thanks,
MB.

Comments

  • edited June 2003
    Hi Moisey,

    The simplest way to do this would be to load all the reports you need to
    print either manually or dynamically into a single report using section
    style subreports. Then when you print the single combined report, the print
    settings will remain for all the reports you loaded. Below is an article on
    creating subreports in code.

    -------------------------------------------------
    TECH TIP: Creating a SubReport in Code
    -------------------------------------------------

    A subreport is comprised of two objects:

    1. SubReport control
    The subreport control is added to a band of the
    'parent' report. It has properties such as
    ShiftRelativeTo, PrintBehavior, etc.
    In the Report Designer, the subreport is drawn
    as a rectangle.


    2. ChildReport
    The child report is a descendant of CustomReport and has
    most of the same properties as a standard Report.
    The child report has a separate layout workspace in the report
    designer that is accessible by selecting the tabs at the bottom
    of the designer.




    When dynamically creating a subreport in code you need to
    create the subreport and the underlying child report.
    The subreport.Report property can then be used to access
    the child report.

    This is demonstrated in the following example:




    var
    lSubReport: TppSubReport;
    lReport: TppChildReport;
    lLabel: TppLabel;
    lDBText: TppDBText;


    begin

    lSubReport := TppSubReport.Create(Self);

    {add to the main report's detail band}
    lSubReport.Band := ppReport1.DetailBand;

    {create the child report (parameters: main report) }
    lSubReport.CreateReport(ppReport1);

    lReport := TppChildReport(lSubReport.Report);

    {assign a datapipeline}
    lReport.DataPipeline := plCustomers;

    {create the default set of bands}
    lReport.CreateDefaultBands;

    lLabel := TppLabel.Create(Self);
    lLabel.Band := lReport.TitleBand;
    lLabel.Caption := 'Customers';

    lLabel.Font.Name := 'Times New Roman';
    lLabel.Font.Size := 24;

    lDBText := TppDBText.Create(Self);
    lDBText.Band := lReport.DetailBand;
    lDBText.DataPipeline := plCustomers;
    lDBText.DataField := 'CustNo';

    lDBText.Color := clYellow;
    lDBText.Font.Name := 'Times New Roman';
    lDBText.Font.Size := 12;



    end;


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Ok, thanks for the tip, but it is too hard for what I need to do.
    Can I simply suppress printer settings dialog popup then? So that only
    default values would be taken into account before printing?


  • edited July 2003
    Moisey,

    Instead of loading subreports, you could send multiple report objects to the
    printer, and in each report after the first one, set the
    Report.ShowPrintDialog property to False. To save the print settings, you
    will need to assign the print settings of the first printed report to the
    print settings of the other reports before the first report finishes
    printing. You could also save down the DevMode structure for the first
    report and use that on the others. Below is an article on how the Printer
    Devmode works.

    -------------------------------------------------
    Tech Tip: Configuring Printer Specific Options
    -------------------------------------------------

    The Report.PrinterSetup properties can be used to set the properties that
    are common to all printers. Internally RB applies these to the Windows
    DevMode structure.


    Report.PrinterSetup <----> Windows DevMode <-----> Printer Driver <--->
    Printer


    Printers often contains additional features, such as output bins, media
    types, etc. The Windows DevMode structure can contain a private area that is
    used the printer driver to store printer specific options. These can be
    configured by using the Printer Driver's built-in properties dialog. These
    options can theoritically be set programmatically, the trick is that you
    have to know where in the structure to store the option and what values are
    valid.

    The following example shows how to display the printer properties dialog and
    save the devmode for use within RB...

    http://www.digital-metaphors.com/tips/SavePrinterDevMode.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Cool, that seems to be a proper solution for me.

    Although, could you pleasse explain it in more details?.
    By "print settings of the first printed report" do you mean
    TppReport.PrinterSetup property?
    By "before the first report finishes printing" do you mean
    TppReport.OnAfterPrint event?

    Thanks,
    MB.

  • edited July 2003
    Also your example "SavePrinterDevMode.zip" in tech tips is not working how
    it is supposed to.

    First:
    I'm pressing the "Printer Properties" button and change several settings.
    Afterwards:
    If I am pressing "Print" button and "Print" button in the preview dialog
    then the settings are applied.
    If I am pressing "Print with no dialog" button then the settings are not
    applied and the report is printed as is with default printer setings.

    What could be the reason?

    Thanks,
    MB.

This discussion has been closed.