2013-09-23 99 views
1

此代碼將只打印一頁,但控件的高度超過頁面高度,因此需要在第二頁上打印。我一直在調查什麼能夠讓控制權進入另一個頁面。我儘可能使用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"); 

      } 

回答