如何使用.NET将报告打印到所选打印机,SAP Crystal在64位服务器(Win2k8)上报告引擎64位?

时间:2014-07-24 18:59:25

标签: c# .net printing crystal-reports

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

CrystalDecisions.CrystalReports.Engine,CrystalDecisions.ReportSource& CrystalDecisions.Shared是从

引用的DLL

C:\ Program Files \ sap businessobjects \ crystal报告.net framework 4.0 \ common \ sap businessobjects enterprise xi 4.0 \ win32_x86

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

C:\ Program Files \ sap businessobjects \ crystal报告.net framework 4.0 \ common \ sap businessobjects enterprise xi 4.0 \ win64_x64

我找不到任何代码问题,我认为这绝对是一个兼容性问题。我被困这个问题超过一个月了。请帮忙。

1 个答案:

答案 0 :(得分:4)

我们发现了问题和解决方法。它与代码有关。

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

reportDocument.PrintOptions.PrinterName即使分配了正确的打印机名称也始终为空。代码已更改如下,并且在具有现有设置安装的Windows Server 2008 R2上也是如此(SAP Crystal报告32位/ 64位版本 - 13.0.3),甚至没有转换为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);