I'm just starting on a contract generation routine for my current project and one of the requirements is that each of the lines in the contract must be numbered. The number should be located in the left margin with a vertical rule separating the numbering from the rest of the document content.
I'm pretty sure I can tackle this requirement with a FixedDocument, but it won't be fun. Is there anyway I can do this with a FlowDocument instead?
You can do this with a FixedDocument quite easily with my WpfPrint helper class, posted below. To use it for XPS creation just use the constructor for XPS:
You can now loop through and add whatever you want; TextBlocks would most likely be what you were looking for:
They'll wrap themselves if you create them wrapped; each item, as it is added, is measured. If it doesn't fit on the page, the helper class adds a new page and flows it onto the new page, so you get what you wanted from FlowDocument. You can change CurX and CurY at any time to skip horizontal or vertical space when placing items. When you are done, you can print to a printer like this:
Or you can save as an XPS file:
Here is the helper class. Enjoy! You'll never want to use a FlowDocument again :-)