【发布时间】:2014-01-15 22:18:30
【问题描述】:
我正在使用 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);
}
当我调用 PrintToPrinter 方法时:
crReportDocument.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
执行最多需要两分半钟。无论是在 Visual Studio 中运行代码,还是在服务器上作为已部署的服务,我都会看到这种行为。
我们最近将我们的服务服务器和打印服务器升级到了 windows 2012。之前,我们的服务服务器是 Windows 2008,我们的打印服务器是 Windows 2003。我们的设置没有这个问题。
有没有人遇到过打印到打印机需要很长时间的问题,或者打印到 Win2012 打印服务器的问题?
谢谢?
【问题讨论】:
标签: c# printing crystal-reports