2011-09-28 13 views
6

प्रिंटिंग में एकाधिक कॉलम से बचें मैं फ़्लो डॉक्यूमेंट से प्रिंट करने के लिए कोड लिख रहा हूं।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 की कॉलमविड्थ सेट करने की आवश्यकता है।

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

इसके लिए धन्यवाद, मेरे पास छोटे दस्तावेज़ हैं और मेरे सिर को खरोंच कर बैठे हुए सोच रहे थे कि मेरे पृष्ठ का केवल आधा उपयोग क्यों किया जा रहा था। मुझे आश्चर्य है कि उन्होंने डिफ़ॉल्ट रूप से दो कॉलम क्यों ले लिए? – Mishax

संबंधित मुद्दे