C# 为什么Crystal Reports PrintTopPrinter方法如此缓慢

C# 为什么Crystal Reports PrintTopPrinter方法如此缓慢,c#,printing,crystal-reports,C#,Printing,Crystal Reports,我使用的是visual studio 2010内部的Crystal Reports,版本13。我有一个运行Windows 2012的打印服务器。我在运行时动态地设置打印机,因为我有大约30台打印机,报表可以转到这些打印机。所有这些打印机都是在打印服务器上配置的 PrintDocument pDoc = new PrintDocument(); PrintLayoutSettings PrintLayout = new PrintLayoutSettings(); PrinterSettings

我使用的是visual studio 2010内部的Crystal Reports,版本13。我有一个运行Windows 2012的打印服务器。我在运行时动态地设置打印机,因为我有大约30台打印机,报表可以转到这些打印机。所有这些打印机都是在打印服务器上配置的

PrintDocument pDoc = new PrintDocument();
PrintLayoutSettings PrintLayout = new PrintLayoutSettings();
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = pq.printerName;
PageSettings pSettings = new PageSettings(printerSettings);
crReportDocument.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;
crReportDocument.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

OnMessageLogged(TraceEventType.Information, "PrePrint " + crReportDocument.PrintOptions.PrinterName);

WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(IntPtr.Zero);
try
{
    crReportDocument.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
    OnMessageLogged(TraceEventType.Information, "Printed " + pq.printerName);
}
catch (Exception eprint)
{
    OnMessageLogged(TraceEventType.Information, "****Failed to Print** to printer " + pq.printerName + " Exception " + eprint.ToString());
}
finally
{
    // Resume impersonation
    ctx.Undo();
    OnMessageLogged(TraceEventType.Information, "Success Printing to " + pq.printerName);
}
调用PrintTopPrinter方法时:

crReportDocument.PrintTopPrinter(printerSettings,pSettings,false,PrintLayout)

执行过程最多需要两分钟半。无论是在VisualStudio中运行代码,还是作为服务器上部署的服务,我都会看到这种行为

我们最近将服务服务器和打印服务器升级到windows 2012。以前,我们的服务服务器是Windows 2008,打印服务器是Windows 2003。我们的设置没有这个问题

是否有人遇到过打印到打印机需要很长时间的问题,或打印到Win2012打印服务器的问题


谢谢?

此问题是由crystal 13 basic运行时中的错误引起的

如果使用“无打印机”选项保存报告,则将忽略设置打印机名称。因此,开发人员必须分配报表文档的整个PrinterSettings属性。这就是延迟发生的地方

// This is the old and reliable way - didn't work for version 13
Settings = new PrinterSettings();
Settings.PrinterName = "HP Printer";
// you don't even need the PrinterSettings object in  10.5, just the printer name
_report.PrintOptions.PrinterName = Settings.PrinterName;
// for version 13 you have to assign the printer settings
if(_report.PrintOptions.PrinterName != Settings.PrinterName)
    _report.PrintToPrinter(Settings, new PageSettings(), false);
我从10.5(basic2008)升级过来,它的打印速度非常快,但由于这个(未确认的)错误,我不得不经历一次困难的回滚

我目前正在研究从晶体,看看这个问题是否已得到解决

编辑

PrintTopPrinter速度慢的问题现已解决,但SAP建议我们使用:

report.ReportClientDocument.PrintOutputController.PrintReport(选项)

而不是PrintTopPrinter,因为它不会得到进一步的开发。

使用

_report.ReportClientDocument.PrintOutputController.PrintReport(popt); 
它比report.PrintTopPrinter快5-10倍,而不是
\u report.PrintTopPrinter
。 我的代码示例:

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions popt = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
popt.PrinterName = printerSettings.PrinterName;
_report.ReportClientDocument.PrintOutputController.PrintReport(popt);

在CR 13.06上测试,
PrintToPrinter
花费了约3800毫秒,而
PrintReport
只花费了约320毫秒,当我使用上述行时,我得到clientdoc.iscdreportcleintdocument不包含“PrintOutputController”的定义,并且没有扩展方法“PrintOutputController”接受参数错误。你能帮忙吗!您使用的运行时版本是否正确?该属性是版本13。看见