setting the printer in runtime

MSCMSC
edited 6:50PM in FastReport Studio
Hi,

a simple question:
invoking a report with a parameter (organizationId), should control on which printer will be printed.
Example: Parameter organizationId has the value 100, should be printed on printer \\printserver\P470;
organizationId has the value 150, should bi printed on printer \\printserver\P480.

How can i code this?

thx for help

Comments

  • MSCMSC
    edited 6:50PM
    mithcd wrote: »
    Try this.
    uses printers,....
    ....
    ....
    ....
    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;
    

    Thx for your reply. This example is the right one...

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.