XPS Packaging Policy Sample
The XpsFlatFile sample shows how to implement a custom derived override of the BasePackagingPolicy class that serializes XPS documents to a different type of physical data store.
The default packaging policy provided with Windows Presentation Foundation (WPF) uses Zip files (based on the ZipPackage class) as the physical store for writing and reading XpsDocument files. The XpsFlatFile sample implements a custom derived BasePackagingPolicy class to serialize the content of XML Paper Specification (XPS) documents to a non-zipped flat-file organization. The XpsFlatFile sample operates similar to the Creating an XPS Document Sample, however instead of writing the to a Zip file, the XPS document parts are written to an unzipped "\Output" folder. (By zipping the \Output folder and its subdirectories, and then renaming the file name extension to ".xps", you can view the XPS document by using the standard XpsViewer application.)
By implementing a custom BasePackagingPolicy override, the physical store for XPS document serialization can be easily changed. For more information about the XpsFlatFile sample, see the "XpsFlatFile.doc" file provided with the sample source code.
This sample demonstrates a specific feature of the WPF and, consequently, does not follow application development best practices. For comprehensive coverage of 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
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 compiled sample from the build environment command window, execute the .exe file in the Bin\Debug or Bin\Release folder contained under the sample source code folder.
To run the compiled sample with debugging in Visual Studio 2005, press F5.