Problem printing multiple reports
I am loading a series of reports from a database and printing them each in
turn. The user selects the printer on the first report and in theory it
should print on the printer they select for each report, but only the
first one does this, the rest all go to the default printer.
I have a global variable: FReportPrinterSetUp : TppPrinterSetup;
in the PrintDialogClose event, I do this:
FReportPrinterSetUp := TppPrinterSetup.Create(nil);
FReportPrinterSetUp.Assign(TppPrinter(.PrintDialog.Printer).PrinterSetUp);
then in the printing loop, after loading but before printing, I do this:
myReportReader.ShowPrintDialog := not Assigned(FReportPrinterSetUp);
if Assigned(FReportPrinterSetUp) then
myReportReader.PrinterSetUp.Assign(FReportPrinterSetUp);
Where am I going wrong?
--
Jeremy Knowles
turn. The user selects the printer on the first report and in theory it
should print on the printer they select for each report, but only the
first one does this, the rest all go to the default printer.
I have a global variable: FReportPrinterSetUp : TppPrinterSetup;
in the PrintDialogClose event, I do this:
FReportPrinterSetUp := TppPrinterSetup.Create(nil);
FReportPrinterSetUp.Assign(TppPrinter(.PrintDialog.Printer).PrinterSetUp);
then in the printing loop, after loading but before printing, I do this:
myReportReader.ShowPrintDialog := not Assigned(FReportPrinterSetUp);
if Assigned(FReportPrinterSetUp) then
myReportReader.PrinterSetUp.Assign(FReportPrinterSetUp);
Where am I going wrong?
--
Jeremy Knowles
This discussion has been closed.
Comments
being saved.
2. When exactly are you assigning the next report's PrinterSetup? I would
suggest using the Template.OnLoadEnd event.
3. If you trace your code below, is the FReportPrinterSetup being assigned
to the new Report.PrinterSetup?
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"Jeremy Knowles"
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Well, they certainly seem to be.
Ah, actually I'm using a TppArchiveReader to do this so there's no
template involved. This is becasue it's a client/server app and the server
produces the report then sends it to the client in raf format. The client
then saves it to a temporary file (can't just load the TMemoryStream
unfortunately), and loads it inot the TppArchiveReader.
They are at the line that does the print, but then the printing goes to
the wrong printer, i.e. not the one in
myReportReader.PrinterSetUp.PrinterDescription which shows the printer I
want it to be, and yet it still comes out on the default printer.
I've managed to create a demo that shows this, so perhaps you'd be able to
see what I've done wrong by looking at this?
--
Jeremy Knowles
Archives behave differently than regular reports. PrinterSetup information
is saved down for each page. You will need to assign any PrinterSetup
properties in the ArchiveReader.OnInitializePrinterSetup event.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"Jeremy Knowles"
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
That fixed it, thanks Nico - you can ignore the e-mail !
--
Jeremy Knowles