Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1775
Xamdatachart print issue
posted

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

Parents Reply Children
No Data