We're using the Report class to print the contents of a XamDataGrid, using a method within a subclass of XamDataGrid that basically looks like this:
Report report1 = new Report();report1.Sections.Add(new EmbeddedVisualReportSection(this));report1.Print();
This is working fine for all of our users except one, who is encountering the following exception in that code:
System.Printing.PrintQueueException: PrintTicket provider failed to retrieve PrintCapabilities. Win32 error: -2147467259
Here's the stack trace:
at MS.Internal.Printing.Configuration.PTProvider.GetPrintCapabilities(MemoryStream printTicket)at System.Printing.PrintTicketManager.GetPrintCapabilitiesAsXml(PrintTicket printTicket)at System.Printing.PrintTicketManager.GetPrintCapabilities(PrintTicket printTicket)at System.Printing.PrintQueue.GetPrintCapabilities(PrintTicket printTicket)at System.Windows.Controls.PrintDialog.UpdatePrintableAreaSize()at System.Windows.Controls.PrintDialog.get_PrintableAreaWidth()at Infragistics.Windows.Reporting.Report.UpdateSettingsFromPrintDialog(PrintDialog printDialog, Boolean dialogDisplayed)at Infragistics.Windows.Reporting.Report.InitializeReport(Boolean showPrintDialog)at Infragistics.Windows.Reporting.Report.Print(Boolean showPrintDialog, Boolean showReportProgressControl, FrameworkElement reportProgressControlOwnedElement)
This blog post http://petterisbetter.com/michael/index.php/2008/09/29/printticket-provider-failed-to-retrieve- has the following to say about this problem:
"If you do not specify your own PrintTicket for print operations, the default UserPrintTicket for the PrintQueue is used, and some print drivers fail to provide valid objects for the UserPrintTicket and DefaultPrintTicket by yielding the above exception. This is essentially a driver problem, but inevitably there will be instances where your software runs on drivers you didn't know about or in environments where driver upgrades may not be possible. Therefore, I recommend always forcing use of your own PrintTicket for all printing operations in WPF, as I did in the above code for the calls to GetPrintCapabilities and WriteAsync methods. Note that each of these methods has an overload that does not take a PrintTicket argument. These are the ones to avoid."
Is there an option for Report.Print() (or an alternative) that we can use to print the grid contents that uses a custom PrintTicket?
Thanks,Jim Honeycutt
Dear Jim... I am having the same problem... I cannot use my AMOS anymore. When trying to access the link you provided, I also cannot access... Would you like to show me the way of fixing it pls... Thanks... Gusman Malaysia..
Jim,
I spoke with a developmer who pointed me to the Report.ReportSettings.PrintQueue object (API doc located here: http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=InfragisticsWPF4.v10.3~Infragistics.Windows.Reporting.ReportSettings~PrintQueue.html),
...which exposes a DefaultPrintTicket and a UserPrintTicket property. These objects are all settable, so you should try to set UserPrintTicket and/or DefaultPrintTicket.
Please try this out and let me know if this works and/or if you have further questions.
Thanks,
Hello Jim,
According to the API document for our Report.Print method: http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=InfragisticsWPF4.Reporting.v10.3~Infragistics.Windows.Reporting.Report~Print.html
...it appears there is no overload specifying a customer PrintTicket object. I will research this a little further with our developers and let you know what options there are.