This part of the Dissecting XPS series will introduce the XPS parts of the Microsoft.NET 3.0 framework and where you should look to get started creating XML Paper Specification documents.
Windows Presentation Foundation, WPF
The XPS classes is a part of the Windows Presentation Foundation, WPF, and is found under the System.Windows.Xps namespace. The Open Packaging Convention classes, used to manipulate the packages is found under the System.IO.Packaging namespace.
To get you started with creating XPS documents with the .NET 3.0 Framework you should read the January 2006 article in the MSDN Magazine by Bob Watson which explains it all. It contains everything you need to know from reading to writing to signing XPS documents.
XPS and XAML
With XAML, Extensible Application Markup Language, you can create nice interfaces and documents using either an XML editor or Microsoft Expression Blend or Design which can export documents to XAML. The .NET 3.0 Framework contains built-in functionality to convert from XAML to XPS which means that if you are building XAML applications you can easily make print functionality into it.
Since XPS is a fixed page format and WPF applications use a flow document style you have to convert your application interface into pages. Luckily the flow documents contains a paginator interface which divides your flow document into pages. Feng Yuan, XPS guru, shows you how to do this and even include margins, headers and footers in a blog post.
Summary
Not much code in this post, there are already enough, but with the links provided above you should get started pretty easy.
I really hope that more applications will get a Save as XPS function, and let’s hope that Adobe don’t go crazy and summons every developer implementing this.
Next post int this series will look at some good XPS utilities for editing, browsing and manipulating XPS files.