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

Read an XPS Document into an XPS OM

· 52CE 我爱测

Describes how to read an existing XPS document from a file into an XPS OM.

Describes how to read an existing XPS document from a file into an XPS OM.

To create an XPS OM from an XPS document, call the IXpsOMObjectFactory::CreatePackageFromFile method.

Before using these code examples in your program, read the disclaimer in Common XPS Document Programming Tasks.

Code Example

The following code example assumes that the initialization described in Initialize an XPS OM has succeeded.

    IXpsOMPackage *package = NULL;

    hr = xpsFactory->CreatePackageFromFile(
        xpsDocumentFilename,
        FALSE,
        &package);

    // package now contains a pointer to the IXpsOMPackage
    // object that has been populated with the contents
    // of the XPS document in xpsDocumentFilename.

    // When finished with the package, release the object.
    if (NULL != package) package->Release();

To create an XPS OM from an XPS document that is stored as a stream, call IXpsOMObjectFactory::CreatePackageFromStream.

Remarks

If you write an XPS OM immediately after you have read an XPS package into it, some of the original content might be lost or changed.

Some of the changes that can occur in such case are listed in the table that follows:

Document feature Action
Digital signatures Removed from the document
DiscardControl part Removed from the document
Foreign document parts Removed from the document
FixedPage markup Modified from the original
Resource dictionary markup Modified from the original, if Optimization flag is set

Related topics

Next Steps

Navigate the XPS OM

Write Text to an XPS OM

Draw Graphics in an XPS OM

Place Images in an XPS OM

Used in This Section

IXpsOMObjectFactory

IXpsOMPackage

For More Information

Initialize an XPS OM

Packaging API

XPS Document API Reference

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)

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

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