2011-09-28 11 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"); 
     } 

このコードは、1ページに複数の列を印刷します。これを避ける方法は?

答えて

10

私は考えました。 FlowDocumentのColumnWidthを設定する必要があります。

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

私は短い書類を持っていて、なぜ私のページの半分だけが使用されていたのか疑問に思っていました。私はなぜ彼らがデフォルトとして2つの列を取ったのだろうか? – Mishax

関連する問題