Choose printer manualy

Is it possible to setup printer manualy? I want to you use procedure PrintPreparedReport, but there as parameter is no printer where to be printed the report (report will be printed on the default printer). ;)

Comments

  • edited 8:59AM
    I found how to do it ;)
  • edited 8:59AM
    Please tell us how you did it.
    Did you use PrintPreparedReportDlg?
    Or did you use Delphi's PrinterSetupDialog?
  • edited 8:59AM
    Hi Schreij!

    There are 2 important method of TFRReport. They are:

    - ChangePrinter(OldIndex,NewInde:Integer); and

    - PrintPreparedReport(PageNumbers: String; Copies: Integer;
    Collate: Boolean; PrintPages: TfrPrintPages);
    //TfrPrintPages = (frAll, frOdd, frEven);//

    The first method changes the actually selected printer to the newly selected printer. These indexes can be obtained from the Printer:TPrinter object Printers:TStrings property. If You pass -1 to the NewIndex it will select the default printer. I usually provide the user the following GUI: there is a TComboBox with Items property assigned to the Printer.Printers list. This assignment fills the combo with the list of installed printers. That list is populated using the printerindex order. So You can assign the combo's ItemIndex property to the ChangePrinter's NewIndex parameter. After this call PrintPreparedReport. I think only the first parameter needs explanation. That is a string containing individual values or ranges like in standard print dialogs. I hope this helps.

    Regards:Alex;
  • edited 8:59AM
    Alex thank you for your answer.

    I use the Delphi PrinterSetupDialog.
    It sets the default Printer (and bin!) for the Application.
    FastReport uses the default printer so I can set the printer for my report.

    The problem is that I want to set the bin for the printer to use in my report.
    I make large series of invoices having the letter and address on page 1 and the amount to pay on page 2. Page 1 uses an other paper then page 2.

    Someone gave me this code to change bin:
    
    procedure TForm1.Button1Click(Sender: TObject);//for choosing the printer
    begin
      listboxPrinter.items.clear;
      listboxPrinter.items.addstrings( prn.Printers );
    end;
    
    procedure TForm1.ListBoxPrinterClick(Sender: TObject);
    begin
      prn.PrinterIndex := listboxPrinter.ItemIndex;
      frReport1.ChangePrinter(0, prn.printerindex);
      listbox1.Items.Clear;
      listbox1.items.addstrings( prn.BinNames );//for choosing for pag 1
      listbox2.Items.Clear;
      listbox2.items.addstrings( prn.BinNames );//for choosing for pag 2
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);//print, using the choosen bin 
    begin
      frreport1.Pages.Pages[0].pgBin := prn.GetBinIndex(listbox1.itemindex);
      frReport1.Pages.Pages[1].pgBin := prn.GetBinIndex(listbox2.itemindex);
      frReport1.PrintPreparedReport('', 1, True, frAll);
    end;
    
    

    But it doesn't function at all, so there must be a error in it.
  • edited 8:59AM
    I found out the correct code:

    These lines are false:
    . frreport1.Pages.Pages[0].pgBin := prn.GetBinIndex(listbox1.itemindex);
    . frReport1.Pages.Pages[1].pgBin := prn.GetBinIndex(listbox2.itemindex);

    The correct lines are:
    . frReport1.Pages.Pages[0].pgBin := prn.Bins[listbox1.itemindex];
    . frReport1.Pages.Pages[1].pgBin := prn.Bins[listbox2.itemindex];

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.