Hi,
I am trying to print a framework element. I am using the following code
"MainContentRegion" in the following code is a content control that holds an infragistics grid.
FrameworkElement fe = (MainContentRegion.Content as FrameworkElement); System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket); double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / fe.DesiredSize.Width, capabilities.PageImageableArea.ExtentHeight / fe.DesiredSize.Height); fe.LayoutTransform = new ScaleTransform(scale, scale); fe.Measure(new Size(Int32.MaxValue, Int32.MaxValue)); Size visualSize = fe.DesiredSize; if (fe.DesiredSize.Width >= fe.ActualWidth || fe.DesiredSize.Height >= fe.ActualHeight) fe.Arrange(new Rect(new Point(0, 0), visualSize)); MemoryStream stream = new MemoryStream(); string pack = "pack://temp.xps"; Uri uri = new Uri(pack); DocumentPaginator paginator; XpsDocument xpsDoc; DocumentViewer doc = new DocumentViewer(); Window _window = new Window(); using (Package container = Package.Open(stream, FileMode.Create)) { PackageStore.AddPackage(uri, container); using (xpsDoc = new XpsDocument(container, CompressionOption.Fast, pack)) { XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false); rsm.SaveAsXaml(Grid.Content);
paginator = ((IDocumentPaginatorSource) xpsDoc.GetFixedDocumentSequence()).DocumentPaginator;
paginator.PageSize = visualSize;
paginator = new VisualDocumentPaginator(paginator, new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight), new Size(10, 10));
doc.Document = xpsDoc.GetFixedDocumentSequence();
_window.Content = doc; _window.ShowDialog();
printDlg.PrintDocument(paginator, "A Flow Document"); }
PackageStore.RemovePackage(uri); }
I have to use measure and arrange to get all the data from the grid which is not visible( grid contains a scroll bar). But when i use measure and arrange on the frame work element above Xamdatagrid responds correctly where as xamdatachart doesnot fit into the page(A4) and more over it overlaps with xamdatagrid.
Regards,
Sasikumar
Hi Stephan,
I think the topic that you have shared refers to saving Xamdatachart as an image. And moreover it uses infragistics reporting framework. I am not using either of them. As the sample code suggests i am using a flow document approach, and when the view(Framework Element/Content Control) contains both Xamdatachart(scatter Line series) and Xamdatagrid.On print operation (code shared in 1st post) the chart control either overlaps with the grid or goes out of the page. I have tried skipping measure and arrange operation for a view with both, in that case the contents of the grid are not fully displayed.
Hello Sasikumar,
Thank you for your post. I have been looking into it and I can suggest you see this blog:
http://ko.infragistics.com/community/blogs/petar_monov/archive/2012/03/14/controls-to-images.aspx
where Peter explained how to export controls to Excel, .png, .jpg. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.