水晶报表|印刷|默认打印机报表、打印机、水晶

2023-09-02 02:03:34 作者:涐还有多少感情能任沵挥霍

我在做一个应用程序,其中用户将打印发票,我用水晶报表显示很

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

用户向我展示了使用ForPro了他当前的应用程序。在这种应用中,在打印机选项对话框,可以看到当前已安装的所有打印机,用户可以选择默认打印机。当发票后,用户presses打印按钮,然后有一个对话框,询问没有。的副本。当它进入,发票被直接印刷,无需任何打印对话框。如果用户想要再次改变打印机,他/她将在打印机选项的形式改变它。

The user showed me his current application made using ForPro. In that application, under Printer Options form, one can see all the printers currently installed and the user could select default printer. When the invoice is made, the user presses the print button, then there is one dialog asking for no. of copies. When it's entered, the invoice gets printed directly, without any Print Dialog Box. If the user wants to change the printer again he/she will change it in the Printer Option form.

我想知道,如果类似的事情有可能在水晶报表,需要对如何处理它的指导。

I want to know if similar thing is possible in Crystal Report and need guidance on how to approach for it.

推荐答案

看看该ReportDocument.PrintToPrinter SAP文档或的 MSDN文档如何指定PrinterName的,然后打印使用的ReportDocument对象。

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.

如果你可以尝试从如何脱身的FoxPro应用程序的用户界面的打印机选择。相反,使用标准的打印对话框选择打印机。

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.

您应该注意,如果您将报告发送到打印机之前不设置PrinterName的,将使用默认的水晶文件上。为了不被混淆与用户的操作系统默认打印机。

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.

下面是一个使用的 SetParameterValue 方法,然后将报告发送文件到打印机

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<bool> 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);
}