【问题标题】:active reports always sends to default printer活动报告总是发送到默认打印机
【发布时间】:2013-05-08 10:21:28
【问题描述】:

我想从活动报告打印到网络打印机,但它总是打印到默认打印机而不会​​引发错误。 一旦我尝试使用 .net printdocument 库进行打印,它就会打印到指定的打印机。

我不知道为什么在使用 activereports 时它会打印到默认打印机。

【问题讨论】:

    标签: printing activereports


    【解决方案1】:

    设置打印机对象的PrinterName property。类似于以下内容:

    viewer.Document.Printer.PrinterName = "TheNetworkPrinterName";
    viewer.Print();
    

    PrinterName 属性的值应该是 windows 中的确切名称。要获取给定系统上的有效打印机名称列表,您可以使用 PrinterSettings.InstalledPrinters 枚举打印机列表。 the MSDN documentation here 是枚举可用打印机的示例。

    如果您尝试某项操作并发现它不起作用,请向我们提供更详细的信息,我们会尽力为您提供帮助。

    【讨论】:

    • 您好,感谢您的回复。我已经分配了打印机名称。但它仍然打印到默认打印机。这是重现问题的示例:hotfile.com/dl/214941957/a8b4362/PrintingSample.rar.html
    • 顺便说一下,我列出了带有 InstalledPrinters 的打印机并使用了列表中显示的名称。
    【解决方案2】:

    在最终用户设计器中更改打印机。

    Grapecityteam 回答:

    对于 SectionReport,您可以在设计器的 LayoutChanged 事件中注入脚本以在加载报表时更改默认打印机,如下所示:

    private void OnLayoutChanged(object sender, LayoutChangedArgs e)
            {
                if (e.Type == LayoutChangeType.ReportLoad || e.Type == LayoutChangeType.ReportClear)
                {
                    reportToolbox.Reorder(reportDesigner);
                    reportToolbox.EnsureCategories();
                    reportToolbox.Refresh();
                    RefreshExportEnabled();
                    CreateReportExplorer();
                    splitContainerMiddle.Panel2Collapsed = reportDesigner.ReportType == DesignerReportType.Section;
    
                    if (reportDesigner.ReportType == DesignerReportType.Section)
                    {
                        string script = string.Empty;
                        script += "public void ActiveReport_ReportStart()";
                        script += "{";
                        script += "rpt.Document.Printer.PrinterSettings.PrinterName = System.Drawing.Printing.PrinterSettings.InstalledPrinters[3];";
                        script += "}";
                        (reportDesigner.Report as SectionReport).ScriptLanguage = "C#";
                        (reportDesigner.Report as SectionReport).Script = script;
                    }
    
                }
    

    感谢 Grapecity 的销售和支持

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多