2011-09-28 94 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