views:

20

answers:

2

I have a WPF with content in it, and would like to print it. Using

PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == true)
   pd.PrintVisual(textStack, "Chinese Pinyin Text");

to print however, means that if I resize my window, some stuff will get cut off. How can I print it and ensure a standard 8.5x11 piece of paper with all my content, so nothing gets cut off and it correctly flows? (IE- My window is widescreen, but when it prints, it should deliver a 8.5 by 11 paper with content correctly flowing).

+1  A: 

You could create a ViewBox that wraps the StackPanel and is sized to the size you want and then print the ViewBox. That might work.

Otherwise, like Patrick said, getting your visual into a FlowDocument and having that handle paging is going to be your best bet.

Foovanadil
I tried the ViewBox, but it seems like it gives the same effect as the StackPanel- if I resize the window, the content in the ViewBox visibly shrinks (things get skinnier but don't wrap)
DMan
+1  A: 

Can you create a FlowDocument (or other XxxxDocument) from it? FlowDocuments are relatively easy to print.

Patrick Szalapski
Perfect! I wrapped my stack panels in `<BlockUIContainer>` and it worked perfectly
DMan