2011-10-16 58 views
2

在WPF/C#應用程序中,我使用DocumentPaginator打印了一些頁面。 但是,我想在Landscape和Portrait模式中混合使用1個打印作業頁面: ,例如,第1頁爲縱向,第2頁爲橫向,第3頁爲縱向。在wpf/c中混合橫向和縱向打印#

但是,如果我更改PageSize(從DocumentPaginator覆蓋)以反映風景,頁面仍保持縱向模式。

換句話說在

public class PrintPaginator : DocumentPaginator 
    { 
     public override Size PageSize { get; set; } 
     public override DocumentPage GetPage(int pageNumber) 
     { 
      // size values 
      Size theSizeOfThePage; 
      // make size orientation correct 
      if (pageNumber == 2) 
      { 
       // landscape: width is larger then height 
       theSizeOfThePage = new Size(Math.Max(PageSize.Width, PageSize.Height), Math.Min(PageSize.Width, PageSize.Height)); 
      } 
      else 
      { 
       // portrait: height is larger then width 
       theSizeOfThePage = new Size(Math.Min(PageSize.Width, PageSize.Height), Math.Max(PageSize.Width, PageSize.Height)); 
      } 
      PageSize = theSizeOfThePage; 

      // set the grid as the page to print 
      thePage = new Grid(); 
      thePage.Width = PageSize.Width; 
      thePage.Height = PageSize.Height; 

      [...] 

      // return a documentpage wrapping the grid 
      return new DocumentPage(thePage); 
     } 

我相信我可以不設置取向或每頁爲橫向更早,因爲這取決於正在打印的頁面編號的...

任何意見,建議, ,workarrounds在1 printjob混合肖像和風景?

謝謝! R.

+0

我沒有做過對你的要求,但會說,其寬度越大則高度在大多數編程實例基本上無效的任何研究。像這樣設置不會旋轉頁面,事實上,大多數語言只會「修復」它認爲不正確的東西,並且會使頁面大小相反。你真的需要尋找一個方向或旋轉命令/功能。 –

回答