Esempio n. 1
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            //double dpi = 150;
            //double mag = dpi / 96;
            //RenderTargetBitmap bmp = new RenderTargetBitmap(Convert.ToInt32(mag * LayoutRoot.ActualWidth), Convert.ToInt32(mag * LayoutRoot.ActualHeight), dpi, dpi, PixelFormats.Pbgra32);
            //bmp.Render(LayoutRoot);
            //Image img = new Image { Source = bmp };

            VisualBrush vb = new VisualBrush(LayoutRoot)
            {
                Stretch = System.Windows.Media.Stretch.None, AlignmentY = AlignmentY.Top
            };
            Grid grid = new Grid {
                Background = vb, Width = LayoutRoot.ActualWidth, Height = LayoutRoot.ActualHeight
            };

            PrintManager.Page = PrintPage.A3_Landscape;
            var doc = PrintManager.GetDocumentFrom(new List <UIElement> {
                grid
            });
            var fixedDoc = PrintManager.FlowToFixed(doc);
            //PrintManager.PrintFixedDoc(fixedDoc, "C:\\test.xps");

            PrintPreviewWindow ppw = new PrintPreviewWindow {
                Owner = MainWindow.Current
            };

            ppw.SetDocument(fixedDoc);
            ppw.ShowDialog();
        }
Esempio n. 2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintManager.Page = PrintPage.A3_Portrait;
            var doc      = PrintManager.GetDocumentFrom(GetLayout());
            var fixedDoc = PrintManager.FlowToFixed(doc);

            PrintPreviewWindow ppw = new PrintPreviewWindow {
                Owner = MainWindow.Current
            };

            ppw.SetDocument(fixedDoc);
            ppw.ShowDialog();
        }
Esempio n. 3
0
        private void FixedDocTest()
        {
            FixedDocument doc     = new FixedDocument();
            FixedPage     page    = new FixedPage();
            PageContent   content = new PageContent();

            (content as System.Windows.Markup.IAddChild).AddChild(page);
            StackPanel panel = new StackPanel();

            GetLayout().ForEach(x => panel.Children.Add(x));
            page.Children.Add(panel);
            doc.Pages.Add(content);

            PrintPreviewWindow ppw = new PrintPreviewWindow {
                Owner = MainWindow.Current
            };

            ppw.SetDocument(doc);
            ppw.ShowDialog();
        }
        public void PrintContent()
        {
            var list = GetPrintContent();

            list.ForEach(x => x.HorizontalAlignment = System.Windows.HorizontalAlignment.Center);
            var part = NavigationManager.GetQueryString("part");

            if (part == "summary")
            {
                PrintManager.Page = PrintPage.A3_Landscape;
            }
            else
            {
                PrintManager.Page = PrintPage.A3_Portrait;
            }
            var flow               = PrintManager.GetDocumentFrom(list);
            var fixedDoc           = PrintManager.FlowToFixed(flow);
            PrintPreviewWindow ppw = new PrintPreviewWindow {
                Owner = MainWindow.Current
            };

            ppw.SetDocument(fixedDoc);
            ppw.ShowDialog();
        }