I’m having trouble getting charts to print using the XPS document related APIs. Our app includes several UserControls in a Grid and some of the UserControls have a ChartPlotter. We have a requirement for printing the grid so that the grid
and all content (including the charts) are scaled to fill the page. The content and range of values for all data and axes on the printed chart images should match the values seen on the screen, but the shape of the charts should be transformed to fit
the appropriate area on the page dedicated to each chart.
I get the output page dimension and set up new transforms for the Grid that contains the UserControls (charts and other). Then I do a Measure/Arrange pass on the Grid, expecting that the charts would be appropriately transformed according to what was
happening to the grid container. When printed, the grid is properly scaled and positioned on the page, but the charts are not scaled as expected. If the charts on the monitor are smaller than the physical page size, they don’t scale up to
fill the space on the paper. If the charts on the monitor are larger than the physical page size, the charts are clipped rather than scaled down to fit the proper space. Other controls in the Grid do resize as expected.
I’d appreciate any guidance you could offer on how to get the charts to scale properly when printing. The charts definitely scale properly as windows are resized on the screen, so it may just be something simple that I’m missing when printing.
I'm new to WPF, so that's definitely a possibility.
I’ve created a modified version of the D3 HelloWorldSample that demonstrates the problem. It’s posted at
http://cid-c53097b576e89f3d.skydrive.live.com/self.aspx/.Public/D3/HelloWorld%7C_PrintXPS.zip. I added a Grid parent element on the ChartPlotter, similar to how our app has a grid with multiple charts in it. Clicking the print button brings
up a simple dialog for choosing to send to the printer or to an XPS file. Sending to an XPS file works fine because we don’t do any transforms on the grid. Printing is problematic as described above. The PrintElement() function in the
PrintManager class does most of the interesting work for setting up the transforms.
Thank you in advance for any assistance or guidance you can offer.