Creating an XPS Document Sample
This sample shows how to write XML Paper Specification (XPS) packages both with and without embedded print tickets. In executing the XpsCreate sample, provided text and image resources are output to two new XPS files, XpsDocument.xps and XpsDocument-withPrintTicket.xps. Double-clicking on either of the .container files opens the document in the Microsoft .NET Framework version 3.0 document viewer. The output .xps files are in fact ZIP files that hold the document's content, resource, relationship, and print ticket elements. By changing the file extension from .container to .zip, you can open the files to see the individual parts. The XpsDocument.xps and XpsDocument-WithPrintTicket.xps files are recreated each time the sample is executed.
This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of Windows Presentation Foundation (WPF) and Microsoft .NET Framework application development best practices, refer to the following as appropriate:
Accessibility - Accessibility Best Practices
Security - WPF Security
Localization - WPF Globalization and Localization Overview
Building the Sample
Procedure Title
Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.
Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.
To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.
To build the sample in Microsoft Visual Studio 2005, load the sample solution or project file and then press CTRL+SHIFT+B.
Running the Sample
To run the sample from a CMD Shell command window, execute the .exe file located in the source folder of the sample.
To run the compiled sample with debugging in Visual Studio 2005, press F5.
See Also
Other Resources
Documents in Windows Presentation Foundation
Document Serialization and Storage
Saving an XPS Document Sample
Read-Write-Sign an XPS Document Sample
Reading a Package Sample
Writing a Package Sample