Skip to content

Advanced Printing with WPF

June 12, 2007

Internal mail that may help developers; read from bottom:

From: Other Ms Employee
You can refer to http://msdn2.microsoft.com/en-us/library/ms749165.aspx, this explains the two types of documents that you may use, FlowDocument or FixedPage. FlowDocument object  supports automatic pagination. You could use DataTemplates that are bound to your dataset to display your data in XAML and the right “selection” of controls (StackPanel, Table, WrapPanel, …) to have this paginated on several pages. But:

· Header or Footer on each page are not automatically inserted

· A repeating row header on each page does not come out-of-the-box

What I did was generating XAML (you could do this using your XSLT transformation) and then serializing the XAML to XPS. During this process I added a header and footer (you also have the page count), so the output was an XPS document.

Feng Yuan has posted a sample of a custom paginator when serializing XAML to XPS at http://blogs.msdn.com/fyuan/archive/2007/03/10/convert-xaml-flow-document-to-xps-with-style-multiple-page-page-size-header-margin.aspx .

We are using Blend to design the forms, make sure to put the FlowDocument object into a Window object at design time, otherwise the FlowDocument will not render and later on just take out the FlowDocument node.

From: Ms Employee
I’ve built an offline reporting solution using XML serialized DataSets and XSLT. My solution is able to print either portrait or landscape automatically using an ActiveX plugin, and I am also able to control page breaks and know how many pages the report it (and display it on each page).

Can I use a WPF Browser Application to improve on this. Since one of my requirements is that they be able to just send a new XSLT (or XAML), it seems like a good fit. However, I haven’t seen a lot of documentation around getting the control that I am getting from XSLT.

Can anyone point to some good docs or examples around spiking a solution to what I am doing today? I’m not worried about databinding, just having a repeatable section, controlling page breaks, and knowing how many pages are going to be printed.

From → WPF

One Comment
  1. Henk permalink

    The thing that bothers me is that everyone is using xslt\’s to spit out xaml just because the data binding story for frameworkcontentelements is not great (to put it mildly). Are there any plans to improve this ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: