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

Retaining Printer setup between reports

edited May 2002 in General
I want to print a series of separate reports one after the other but only
show the print setup dialog for the first one and remember the print
settings for the others.

The reason for this is that I have split down a previous complex set of
subreports into simpler single ones as I find it more reliable and much
easier to debug.

Is there a simple way of retaining Print settings between reports or will I
need to handle all the separate print parameters myself?

Peter Harris

Comments

  • edited May 2002
    Use a single instance of the report object and load the reports as
    templates. Before calling Print for the first time set the
    Report.SavePrinterSetup property to True. After the first report has been
    printed set Report.ShowPrintDialog to false and iterate over the rest of the
    templates to load and print each one.
    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited May 2002
    The problem is that each report works on a different set of data with it's
    own query to work from. I have not used templates though and will look
    into your suggestion.

    Thanks

    Peter

    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited May 2002
    You can attempt the same method by iterating over the individual reports if
    you save the printer setup from the first printed report. For example:

    FReports: array[0..x] of TppReport;
    FPrintSetup: TppPrinterSetup;
    ...
    FReports[0].DeviceType := 'Printer';
    FReports[0].OnPrintDialogClose := DoOnPrintDialogClose;
    FReports[0].Print;

    for liIndex := 1 to x - 1 do
    begin
    FReports[liIndex].ShowPrintDialog := False;
    FReports[liIndex].DeviceType := 'Printer';
    FReports[liIndex].PrinterSetup.Assign(FPrintSetup);
    FReports[liIndex].Print;
    end;

    ...

    { Lastly implement the first report's OnPrintDialogClose event to save the
    printer setup object. }

    procedure TForm1.DoOnPrintDialogClose(Sender: TObject);
    begin
    FPrintSetup := TppPrinterSetup.Create(nil);
    FPrintSetup.Assign(ppReport1.PrinterSetup);
    end;



    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited May 2002
    Thanks - that will do nicely

    Peter


    "Alexander Kramnik (Digital Metaphors)" wrote
This discussion has been closed.