Common XPS Document Programming Tasks
This page lists some of the programming tasks that are commonly performed with the XPS Document API.
The following code examples illustrate some of the programming tasks that are commonly performed when the XPS Document API is used for working with an XPS OM.
- Initialize an XPS OM
- Create a Blank XPS OM
- Read an XPS Document into an XPS OM
- Navigate the XPS OM
- Write Text to an XPS OM
- Draw Graphics in an XPS OM
- Place Images in an XPS OM
- Write an XPS OM to an XPS Document
- Print an XPS OM
- Working with XPS OM Collection Interfaces
Code examples are not intended to be complete and working programs. The code examples that are referenced on this page, for example, do not perform parameter checking, error checking, or error handling. Use these examples as a starting point, and then add the code necessary to create a robust application. For more information about HRESULT return values and error handling strategies, see Error Handling in COM.
Before XPS OM interfaces can be used, COM must be initialized in the thread, as shown in the following example code.
For clarity, these code examples use a very simple XPS OM, one that might not be complex enough for your application. As a case in point, in the code examples that add content to a page, the visual elements of a page are added directly to the page's list of visual objects; in practice, however, you might want to group visual objects into canvas objects, so that multiple objects could be acted upon as a group. Thus, to enable support of the same content for more than one page size, you could group the visual content of a page into a single canvas object, and then apply a transform to the canvas to scale it to the current page size.