我想從活動報告打印到網絡打印機,但它始終打印到默認打印機而不會出現錯誤。 一旦我嘗試使用.net printdocument庫進行打印,它就會打印到指定的打印機。活動報告總是發送到默認打印機
我不知道爲什麼它使用activereports打印到默認打印機。
我想從活動報告打印到網絡打印機,但它始終打印到默認打印機而不會出現錯誤。 一旦我嘗試使用.net printdocument庫進行打印,它就會打印到指定的打印機。活動報告總是發送到默認打印機
我不知道爲什麼它使用activereports打印到默認打印機。
設置打印機對象的PrinterName property。像下面這樣:
viewer.Document.Printer.PrinterName = "TheNetworkPrinterName";
viewer.Print();
的PrinterName
屬性的值應該是從窗戶的確切名稱。要獲得給定系統上的有效打印機名稱列表,可以使用PrinterSettings.InstalledPrinters枚舉打印機列表。枚舉可用打印機的示例是the MSDN documentation here。
如果您嘗試一些操作並發現它不起作用,請提供更詳細的信息,我們會盡力爲您提供幫助。
更改最終用戶設計器中的打印機。
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銷售和支持
嗨,謝謝你的迴應。我已經分配了打印機名稱。但它仍然打印到默認打印機。下面是一個重現此問題的示例:https://hotfile.com/dl/214941957/a8b4362/PrintingSample.rar.html – 2013-05-09 07:01:01
順便說一句,我列出了帶有InstalledPrinters的打印機,並使用列表中顯示的名稱。 – 2013-05-09 07:08:29