Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are some problems with the referenced CodeProject, but it ALMOST works, and I have had success with the following changes:</p> <p>In GetPage, just delete the four lines that reference the Console.</p> <p>In the Definition class add </p> <pre><code>public static Size Subtract( Size s1, Size s2 ) { return new Size( s1.Width - s2.Width, s1.Height - s2.Height ); } </code></pre> <p>and change ContentSize get to </p> <pre><code> return Subtract( PageSize, new Size( Margins.Left + Margins.Right, Margins.Top + Margins.Bottom + HeaderHeight + FooterHeight) ); </code></pre> <p>Then, in your own code, something like this to call it on a button click: -- I didn't like his class name :)</p> <pre><code>PrintDialog printDialog = new PrintDialog( ); printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape; if ( true == printDialog.ShowDialog( ) ) { MyPaginator.Definition d = new MyPaginator.Definition { Header = ( c, b, n ) =&gt; c.DrawRectangle( Brushes.Black, null, b ), Margins = new Thickness( 48 ), // 1/2 inch all around PageSize = new Size( flowDocument.PageWidth, flowDocument.PageHeight ), }; DocumentPaginator s = new MyPaginator( flowDocument, d ); printDialog.PrintDocument( s, "Print Job Title" ); } </code></pre> <p>In my case, I didn't need a Footer, but that Header delegate (or something like it) is a must. The Margins and PageSize will default, but I wanted different values.</p> <p>Finally, I found that I needed to add <code>KeepTogether = true</code> to my Paragraph definitions for my TableCells.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload