Printing archive ignores user's printer selection
This is an odd issue that may already be fixed. Note that we're using
RB 11.08 and I have implemented a workaround for the issue. I'm only
presenting it here in hopes that if it has not been fixed in the latest
version, that it is fixed before we update RB again!![:) :)](https://digital-metaphors.com/forums/resources/emoji/smile.png)
I'm migrating a project from RB7/D6 to RB11/DXE. This behavior does
not occur in RB7.
This project will print a previously archived report. We set
ShowPrintDialog to True to allow the user to specify the
printer/properties when printing.
The problem is that if the user switches to a different printer using
the dialog, ReportBuilder ignores the selection and always prints to
the default printer.
I've narrowed this down to a couple of issues in the source:
ppArchive.Pas:TppCustomArchiveReader.ReadPageFromFile destroys the
current TppPage object and creates a new one before reading each page
of the archived report.
ppDevice.pas:TppPage.Create creates a TppPrinterSetup object for the
page object (that was created by ReadPageFromFile).
This new TppPrinterSetup object does not contain any of the properties
that were set by the user in the printer dialog.
ppArchive.pas:TppCustomArchiveReader.InitializePrinterSetup copies
FPage.PrinterSetup to the local PrinterSetup. At this point, the
printer selected by the user in the dialog is lost and the printer
becomes "default".
Right below that line, there is code to "preserve printer job
settings". However this is too little too late. Stepping through
InitializePrinterSetup:
if ReadFirstPage then
begin
FPrinterSetupInitialized := True;
{ At this point, both FPrinterSetup and
PrinterDevice.Printer.PrinterSetup reflect the printer that the user
choose in the print dialog (HP LasterJet 1200 Series PCL 5):
(True, 'Default', True, True, 1, 'Installed Media', dpNone, '',
$C4870C0, (ppPrintr.TppPrinter.PrinterSetupGetPrinterEvent,$7391BD8),
(nil,nil), (ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8),
(ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8), poLandscape,
$C487098, 'Letter', 'HP LaserJet 1200 Series PCL 5', nil, utInches,
False, 129695852, 15, 0, $C4870E8, 0, 0, $5ECE508, False)
}
PrinterSetup := FPage.PrinterSetup;
{ At this point, PrinterDevice.Printer.PrinterSetup now reflects the
exact same thing as FPage.PrinterSetup and PrinterSetup above. So the
code to preserve printer job settings is not doing the intended job.
All three PrinterSetup references reflect this:
(True, 'Default', True, True, 1, 'Installed Media', dpNone, '',
$C4870C0, (ppPrintr.TppPrinter.PrinterSetupGetPrinterEvent,$7391BD8),
(nil,nil), (ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8),
(ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8), poLandscape,
$C487098, 'Letter', 'Default', nil, utInches, False, 0, 15, 0,
$C4870E8, 0, 0, nil, False)
So the print job always goes to the default printer.
This code below is useless, as PrinterDevice.Printer.PrinterSetup was
altered above when FPage.PrinterSetup was assigned to PrinterSetup.
}
// preserve printer job settings
if (PrinterDevice <> nil) then
PrinterSetup.AssignJobDef(PrinterDevice.Printer.PrinterSetup);
Has this been corrected since 11.08?
Thanks
RB 11.08 and I have implemented a workaround for the issue. I'm only
presenting it here in hopes that if it has not been fixed in the latest
version, that it is fixed before we update RB again!
![:) :)](https://digital-metaphors.com/forums/resources/emoji/smile.png)
I'm migrating a project from RB7/D6 to RB11/DXE. This behavior does
not occur in RB7.
This project will print a previously archived report. We set
ShowPrintDialog to True to allow the user to specify the
printer/properties when printing.
The problem is that if the user switches to a different printer using
the dialog, ReportBuilder ignores the selection and always prints to
the default printer.
I've narrowed this down to a couple of issues in the source:
ppArchive.Pas:TppCustomArchiveReader.ReadPageFromFile destroys the
current TppPage object and creates a new one before reading each page
of the archived report.
ppDevice.pas:TppPage.Create creates a TppPrinterSetup object for the
page object (that was created by ReadPageFromFile).
This new TppPrinterSetup object does not contain any of the properties
that were set by the user in the printer dialog.
ppArchive.pas:TppCustomArchiveReader.InitializePrinterSetup copies
FPage.PrinterSetup to the local PrinterSetup. At this point, the
printer selected by the user in the dialog is lost and the printer
becomes "default".
Right below that line, there is code to "preserve printer job
settings". However this is too little too late. Stepping through
InitializePrinterSetup:
if ReadFirstPage then
begin
FPrinterSetupInitialized := True;
{ At this point, both FPrinterSetup and
PrinterDevice.Printer.PrinterSetup reflect the printer that the user
choose in the print dialog (HP LasterJet 1200 Series PCL 5):
(True, 'Default', True, True, 1, 'Installed Media', dpNone, '',
$C4870C0, (ppPrintr.TppPrinter.PrinterSetupGetPrinterEvent,$7391BD8),
(nil,nil), (ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8),
(ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8), poLandscape,
$C487098, 'Letter', 'HP LaserJet 1200 Series PCL 5', nil, utInches,
False, 129695852, 15, 0, $C4870E8, 0, 0, $5ECE508, False)
}
PrinterSetup := FPage.PrinterSetup;
{ At this point, PrinterDevice.Printer.PrinterSetup now reflects the
exact same thing as FPage.PrinterSetup and PrinterSetup above. So the
code to preserve printer job settings is not doing the intended job.
All three PrinterSetup references reflect this:
(True, 'Default', True, True, 1, 'Installed Media', dpNone, '',
$C4870C0, (ppPrintr.TppPrinter.PrinterSetupGetPrinterEvent,$7391BD8),
(nil,nil), (ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8),
(ppPrintr.TppPrinter.PrinterSetupChangeEvent,$7391BD8), poLandscape,
$C487098, 'Letter', 'Default', nil, utInches, False, 0, 15, 0,
$C4870E8, 0, 0, nil, False)
So the print job always goes to the default printer.
This code below is useless, as PrinterDevice.Printer.PrinterSetup was
altered above when FPage.PrinterSetup was assigned to PrinterSetup.
}
// preserve printer job settings
if (PrinterDevice <> nil) then
PrinterSetup.AssignJobDef(PrinterDevice.Printer.PrinterSetup);
Has this been corrected since 11.08?
Thanks
This discussion has been closed.
Comments
Thanks for the information. This issue has been fixed for the latest
version of ReportBuilder and there is a patch available for RB 11.08
that solves the problem. Send and email to
support@digital-metaphors.com requesting the patch and we'll send it to you.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com