I am using Crystal Reports, version 13, from inside visual studio 2010. I have a print server that is running Windows 2012. I dynamically set printer at run time, because I have about 30 printers that a report can go to. All these printers are configured on the Print Server.
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);
}
When I call the PrintToPrinter method:
crReportDocument.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
It takes up to two and a half minutes to execute. I see this behavior whether I run the code in Visual Studio, or as a deployed service on a server.
We recently upgraded our services servers, and our print servers to windows 2012. Before, our services server was Windows 2008, and our print server was Windows 2003. We did not have this problem with that set up.
Has anyone experienced problems with printing to a printer taking a long time, or problems printing to a Win2012 Print Server?
Thanks?