Print to non default printer
Hello
I am using FR4 and D 7. In my application I would like to be able to print to two different printers without seeing the printer dialog. I can only get my application printing to the default printer. I did find a snippet from FR2 forum (see below), but am not able to get this to work as it goes to the default. I would like code under one button to print to printer A, and code under another button to print to printer B. Any help is appreciated.
....
var
printer:TPrinter;
index:integer;
begin
printer:= TPrinter.Create;
printer.Printers;
//ListBox1.Items:=printer.Printers;//if it is necessary possible to take list a printer
index:=printer.PrinterIndex;//take current printer
frReport1.ShowPrintDialog:=false;
//we print 1-ouch report on 2 printer
frReport1.LoadFromFile('rep1.frf');
frReport1.ChangePrinter(index,2);//change printer with the current index on printer with index 2.
frReport1.PrepareReport;
frReport1.PrintPreparedReportDlg;
//frReport1.PrintPreparedReport();//possible in the same way use this function
//we print 2-ouch report on 3-m printer
index:=printer.PrinterIndex;//take current printer
frReport1.LoadFromFile('rep2.frf');
frReport1.ChangePrinter(index,3);//change printer with the current index on printer with index 3.
frReport1.PrepareReport;
frReport1.PrintPreparedReportDlg;
end;
Comments
frxReport.LoadFromFile( aReport );
frxReport.PrintOptions.Printer := printerName;
PrinterName is the name as the printer appears in the control panel or devices and printers.
As the name can be changed by the user you will have to establcih a way to determine and use the actual name on the system.