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

Retaining Printer Settings Does Not Work For Me

edited May 2002 in General
Hi,

I am trying to retain the printer settings when several reports must be
loaded from a database template and printed. I call the showprintdialog the
first time through and what every printer settings they choose, I would like
all reports to print with those settings. The first print job goes to the
selected printer from the printsetupdialog but all other reports print to
the users "Default" printer. I have tried several methods of accomplishing
this.

1.) I tried to set the ppReport1.SavePrinterSetup := True; -- This did not
work.

2.) I tried to implement a suggestion by DM (Alexander Kramik) on 5/7/2002
like the following:


{private}
FPrintSetup : TppPrinterSetup;


procedure TForm1.DoOnPrintDialogClose(Sender: TObject);
begin
FPrintSetup := TppPrinterSetup.Create(nil);
FPrintSetup.Assign(Rsb.PrinterSetup);
ShowMessage(FPrintSetup.PrinterName); {THIS ALWAYS SHOWS "Default" for
some reason. No matter what printer was selected. Even though the first
print job goes to the correct printer. Like an HP4100PS}
end;


procedure TForm1.Print_All_Reports(Sender: TObject);
var
FIRSTTIME : Boolean;
begin
FIRSTTIME := True;
ppPrinters.Refresh;
Query1.Open;
while not(Query1.EOF) do
begin
ppReport1.Template.DatabaseSettings.Name :=
Query1.FieldByName('REP_NAME').AsString;
ppReport1.Template.LoadFromDatabase;
ppReport1.DeviceType := 'Printer';
ppReport1.OnPrintDialogClose := DoOnPrintDialogClose;
if FIRSTTIME then
begin
ppReport1.ShowPrintDialog := True;
ppReport1.SavePrinterSetup := true;
FIRSTTIME := False;
end
else
begin
ppReport1.ShowPrintDialog := False;
ppReport1.PrinterSetup.Assign(FPrintSetup);
end;
ppReport1.PrintReport;
Query1.Next;
end;
end;

Is there any other way of accomplishing this? Thanks in advance for any
help with this.


Bo Manry
bmanry@medmanagementllc.com




Comments

  • edited May 2002
    >
    Part of the problem could be that FPrintSetup is copied from the report, not
    the dialog. Only the dialog contains the new setting:

    FPrintSetup.Assign(ppReport1.PrintDialog.PrinterSetup);

    --
    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
  • edited May 2002
    Tom,

    I tried the FPrintSet.Assign(ppReport1.PrintDialog.PrinterSetup) but when I
    compile, I get the following message:

    Undeclared identifier: 'PrinterSetup'

    Doing code completion, PrintDialog does not have a property of PrinterSetup.
    How do I get the printersetup information from the PrintDialog?

    Thanks,

    Bo


  • edited May 2002
    uses
    ppPrintr;

    procedure Foo;
    var
    lPrinterSetup: TppPrinterSetup;
    begin
    ...
    lPrinterSetup := TppPrinter(ppReport1.PrintDialog.Printer).PrinterSetup;
    ...
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.