Printing to Non Default Printer ??
I have a app with a fair number of reports that are already done. I
would like the ability to select the printer to print to in my
application - then have all subsequent reports print to that printer -
until the app is shut down and restarted.
I don't want to change the Windows Default printer. I cannot seem to
figure out how to do this. I have tried changing the
Printer.PrinterIndex value for the System Printer object - but this does
not seem to affect the default printer for the reports.
Is there a way to do this? Or will I have to add something like this to
all my reports??
Example Code that seems to work:
---------------------------------
ppReport_Report.PrinterSetup.PrinterName :=
Printer.Printers[Printer.PrinterIndex];
How do others deal with this issue?
Thank you for any feedback!
Bradley
would like the ability to select the printer to print to in my
application - then have all subsequent reports print to that printer -
until the app is shut down and restarted.
I don't want to change the Windows Default printer. I cannot seem to
figure out how to do this. I have tried changing the
Printer.PrinterIndex value for the System Printer object - but this does
not seem to affect the default printer for the reports.
Is there a way to do this? Or will I have to add something like this to
all my reports??
Example Code that seems to work:
---------------------------------
ppReport_Report.PrinterSetup.PrinterName :=
Printer.Printers[Printer.PrinterIndex];
How do others deal with this issue?
Thank you for any feedback!
Bradley
This discussion has been closed.
Comments
By default, ReportBuilder uses the Windows Default printer as its default
when printing. How are you storing these reports? If you are loading them
from template files, the PrinterSettings object is being saved down with the
template and then being loaded once you load the template. It is for this
reason that you would need to set the PrinterName for each individual report
when printing.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Hello Nico,
I do load the reports from templates - you are correct. So - it looks
like I will modify each report.
However, I would like to understand this a little better.
When you say Windows Default printer - does that mean that when we
change the PrinterIndex property of the Printer object - it will have no
effect on Report Builder? Does RB use the PrinterIndex property at all?
Or does the report (if not loaded from the template) when it is created
print to the currently selected printer (PrinterIndex) or does it also
force the printing to the Windows Default? If this is the case then it
really doesn't matter if the report is loaded from Template or not - I
would still need to change hte PrinterName...
Bare with my questions above - I am just trying to fully understand
this. I have been truly amazed at how easy it is to create a report
with your tool. I have used all the other reporting tools that have
shipped with Delphi and some that haven't - and none compare with Report
Builder.
G. Bradley MacDonald
ReportBuilder does not use Delphi's TPrinter object to handle the printing
of reports, therefore the PrinterIndex property is never used. Instead, it
uses its own set of printer objects, which in turn use the Windows API
directly to communicate with your assigned printer driver. Below is a small
diagram of how ReportBuilder communicates with your printer...
ReportBuilder Printer Objects --> Windows API --> Printer Driver --> Printer
Device
If no specific printer is assigned, ReportBuilder will use your computer's
default printer (assigned in the control panel). This information is
retrieved directly from your win.ini file where the default printer is
defined. All of the ReportBuilder printer objects are located in the
ppPrintr.pas file if you would like to see exactly how it works. See the
TppPrinterList.GetSystemDefaultPrinterName for how RB gets the default
printer. Take a look at TppPrinterList.BuildPrinterList for how RB gets a
list of all available printers.
If a report template is being used and you assigned a printer name for that
template, this printer should automatically be assigned when you try to
print. If you would like to override this property, you can change the
printer settings using the OnLoadEnd event of the template ensuring that the
proper printer is used. See the Tech-Tips newsgroups under the "Templates"
thread for more information on how to do this.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com