打印多页以进行控制

时间:2013-09-23 16:28:51

标签: c# .net wpf pagination

此代码仅打印一页,但控件的高度超出页面高度,因此需要在第二页上打印。我一直在调查什么能使控件进入另一页。我得到了DocumentPaginator并且摆弄了它的大小,使它比sz变量更大更小但没有区别。关于什么控制创建新页面的任何想法?这个大小与分页有关吗?

private void Print()
            {
                var pd = new PrintDialog();
                var document = new FixedDocument();
                var fixedPage = new FixedPage();
                var pageContent = new PageContent();
    System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);
    System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
                MarSheetReport mar = new MarSheetReport();
                document.DocumentPaginator.PageSize = sz;
                Transform originalScale = fixedPage.LayoutTransform;
                //get selected printer capabilities


                fixedPage.LayoutTransform = new ScaleTransform(0.2823293807641634 + 0.2498215560314061, 0.2823293807641634 + 0.2498215560314061);

                fixedPage.Width = sz.Width;
                fixedPage.Height = sz.Height;
                // Add visual, measure/arrange page.
                fixedPage.Children.Add(mar.o);
                fixedPage.Measure(sz);

                fixedPage.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
                fixedPage.UpdateLayout();
                //fixedPage.LayoutTransform = originalScale;

                ((IAddChild)pageContent).AddChild(fixedPage);
                document.Pages.Add(pageContent);
                pd.PrintDocument(document.DocumentPaginator, "My Document");

            }

1 个答案:

答案 0 :(得分:0)

这是一种方法,即从视觉创建位图并在多个页面上打破它。

http://www.codeproject.com/Articles/339416/Printing-large-WPF-UserControls