Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid multiple columns in printing FlowDocument

I am writing code to print from a 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");
        }

This code will print multiple columns in one page. How to avoid this?

like image 907
Nishant Avatar asked Sep 28 '11 21:09

Nishant


1 Answers

I figured out. I need to set the ColumnWidth of FlowDocument.

fd.PagePadding = new Thickness(50);
fd.ColumnGap = 0;
fd.ColumnWidth = printDialog.PrintableAreaWidth; 
like image 169
Nishant Avatar answered Nov 29 '22 07:11

Nishant