2011-09-28 99 views
6

我正在編寫從FlowDocument打印的代碼。避免打印多列FlowDocument

 PrintDialog printDialog = new PrintDialog(); 
     bool? result = printDialog.ShowDialog(); 
     if (result == true) 
     { 
      FlowDocument fd = new FlowDocument(); 
      fd.Blocks.Add(new Paragraph(new Run(String.Format("Message:\r\n{0}\r\n", txtMessage.Text)))); 
      fd.PageHeight = printDialog.PrintableAreaHeight; 
      fd.PageWidth = printDialog.PrintableAreaWidth; 
      printDialog.PrintDocument((fd as IDocumentPaginatorSource).DocumentPaginator, "print test"); 
     } 

此代碼將在一個頁面中打印多個列。如何避免這種情況?

回答

10

我想通了。我需要設置FlowDocument的ColumnWidth。

fd.PagePadding = new Thickness(50); 
fd.ColumnGap = 0; 
fd.ColumnWidth = printDialog.PrintableAreaWidth; 
+1

感謝你們,我有簡短的文件,坐在這裏抓着我的腦袋,想知道爲什麼我的網頁只有一半被使用。我想知道他們爲什麼把兩列作爲默認值? – Mishax