Crystal Report | Printing | Default Printer

前端 未结 2 888
情书的邮戳
情书的邮戳 2020-12-10 09:06

I am making one application where user will print invoices which I am displaying using Crystal Report.

The user showed me his current application made using ForPro.

2条回答
  •  我在风中等你
    2020-12-10 09:06

    Take a look at the ReportDocument.PrintToPrinter SAP Docs or MSDN Docs for how to specify the PrinterName and then Print using the ReportDocument object.

    If you can try and get away from how the FoxPro app UI for printer selection. Instead use the standard print dialog box to select the printer.

    You should note that if you don't set the PrinterName before sending the report to the printer it will use the default on the crystal file. Not to be confused with the user's OS default printer.

    Here's an example of showing the PrintDialog settings some parameters using the SetParameterValue method and then sending the report document to a printer

    // Note: untested
    var dialog = new PrintDialog();
    
    Nullable print = dialog.ShowDialog();
    if (print.HasValue && print.Value)
    {
        var rd = new ReportDocument();
    
        rd.Load("ReportFile.rpt");
        rd.SetParameter("Parameter1", "abc");
        rd.SetParameter("Parameter2", "foo");
    
        rd.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
        rd.PrintToPrinter(1, false, 0, 0);
    }
    

提交回复
热议问题