如何在 64 位服务器 (Win2k8) 上使用 .NET、SAP Crystal reports Engine 64 位将报表打印到所选打印机?

Sri*_*ri7 1 .net c# printing crystal-reports

我们有一个基于 .NET 远程处理构建的 Windows 应用程序。它\xe2\x80\x99是使用.NET Framework 2.0构建的32位应用程序。我们使用 .NET Framework 4 的 SAP Crystal reports 运行时引擎(32 位 \xe2\x80\x93 版本 13.0.3)来实现报告功能。还有一个打印功能,可以在批处理运行期间将相应的报告打印到用户选择的打印机上。整个设置在 Windows Server 2003 服务器上运行良好。现在我们正在尝试将应用程序迁移到Windows Server 2008,但打印无法正常工作。它始终将报告打印到 Windows Server 2008 计算机上的默认打印机,而不是打印到所选打印机。

\n\n

CrystalDecisions.CrystalReports.Engine、CrystalDecisions.ReportSource 和 CrystalDecisions.Shared 是引用自的 DLL\xe2\x80\x99s

\n\n

C:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise xi 4.0\\win32_x86

\n\n

我们将应用程序转换为 64 位版本。在 Windows Server 2008 上,即使我们安装了 .NET Framework 4 的 SAP Crystal reports 运行时引擎(64 位 \xe2\x80\x93 版本 13.0.3),打印也无法正常工作(始终打印到默认打印机) )。在64位安装文件夹中也找不到\xe2\x80\x99s上述DLL\xe2\x80\x99s。

\n\n

C:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise xi 4.0\\win64_x64

\n\n

我找不到\xe2\x80\x99t任何代码问题,我认为\xe2\x80\x99s肯定是兼容性问题。我被这个问题困扰了一个多月了。请帮忙。

\n

Sri*_*ri7 5

我们找到了问题并解决了问题。它与代码有关。

string printPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string rptFileName=@"\sample.rpt";
string PrinterName=Console.ReadLine();

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
reportDocument.PrintOptions.PrinterName = PrinterName;           
reportDocument.PrintToPrinter(1, true, 0, 0);
Run Code Online (Sandbox Code Playgroud)

即使分配了正确的打印机名称,reportDocument.PrintOptions.PrinterName 也始终为空。代码已更改如下,并且在具有现有设置安装(SAP Crystal 报告 32 位/64 位版本 - 13.0.3)的 Windows Server 2008 R2 上也能正常工作,甚至无需转换为 64 位。

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = PrinterName;
reportDocument.PrintToPrinter(printerSettings, new PageSettings(), false);
Run Code Online (Sandbox Code Playgroud)