大网数据广告活动
打印与设备

Common XPS Document Programming Tasks

· 52CE 我爱测

This page lists some of the programming tasks that are commonly performed with the XPS Document API.

This page lists some of the programming tasks that are commonly performed with the XPS Document API.

Common XPS Document Tasks

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

Disclaimer

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.

    HRESULT hr;
    hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

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.

Related topics

Error Handling in COM

XML Paper Specification

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。