We have a multipage FlowDocument report that we are developing in WPF that uses charts. When we view the FlowDocument we can see the charts, however when we print the flowdocument the charts do not show on the printed material (we tried printing to different printers including pdf documents, xps document, actual printed paper).
We have found that, if we manually page through the FlowDocument (look at each page) and then print, the charts show in the printed material. It's almost as if the charts need to be viewed or displayed before they can be printed.
I would like to get to the point where I do not need to view the FlowDocument and just print the report in batch.
As for printing .... here is the code that I'm using to print the FlowDocument
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
FlowDocument mainFlow = m.mainFlow;
// Save all the existing settings.
double pageHeight = mainFlow.PageHeight;
double pageWidth = mainFlow.PageWidth;
// Make the FlowDocument page match the printed page.
mainFlow.PageHeight = printDialog.PrintableAreaHeight;
mainFlow.PageWidth = printDialog.PrintableAreaWidth;
// Reapply the old settings.
mainFlow.PageHeight = pageHeight;
mainFlow.PageWidth = pageWidth;
IDocumentPaginatorSource ps = mainFlow as IDocumentPaginatorSource;
printDialog.PrintDocument(ps.DocumentPaginator, "FlowDoc");
}
Any updates on this issue - preferably a bug number and a workaround?
It seems though I fixed this bug recently, later changes before the service release caused a different problem to interfere with what you are trying to do here. I'll get back to you with a bug number tomorrow. Sorry for the frustration.
-Graham
This sounds like a bug that was fixed recently. It was either fixed too recently to make it into the service release you are testing against, or perhaps your case represents a different incarnation of the problem. I'll try to ascertain whether the issue still exists in the latest codebase.
Thank you!
I will look at this and get back to you.
I'm attempting to batch-print UserControls. Essentially, each user control represents a report in our product. The problem I'm running in to is that each report won't print the XamChart or XamDataGrid unless the chart/grid has been displayed on the screen.
It appears as though there is some painting mechanism in the control that won't actually display the chart until it is forced on to the screen. If I host each user control in a form, briefly show/close the form, THEN print, everything displays properly. But if I don't display the control prior to printing, then the charts and grids are completely blank in the printed document.
I have tried this with several user controls, and the only ones that give me grief are those hosting an infragistics component (in this case, XamChart and XamDataGrid).
I have noticed similar behaviour reported in other posts (such as http://forums.infragistics.com/forums/p/7357/30278.aspx#30278 and http://news.infragistics.com/forums/p/7357/30431.aspx#30431). One person mentions that they have to display the item on the screen first before printing, the other states that because the first page shows up in the print preview, it prints properly, but the charts on the subsequent pages don’t print. Note that I am printing to XPS, not to a printer.
Attached is some sample code that reproduces the issue. The command line project prints the reports. The UI project is for demonstration purposes, showing that the user control does in fact have a chart in it.
Here is a breakdown of the output:
1) Using the native XpsDocument class, try printing the user control without showing it. (FAIL)
2) Using the native XpsDocument class, show a dialog with the user control in it, THEN print it. (PASS)
3) Using the Infragistics Report class, try printing the user control without showing it. (FAIL)
4) Using the Infragistics Report class, show a dialog with the user control in it, THEN print it. (PASS)
Note that I only included the Infragistics reporting classes to prove that the issue is not in the native XpsDocument classes, and exists in the chart itself.
I have duplicated the problem using the sample code with both 2010.3 by itself and with the SR applied.
Wasn't sure how to add the code the post, so I tried inserting a ZIP file with the code as a media file. Hope this works okay.