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

Working with IXpsOMDocument Interfaces

· 52CE 我爱测

This topic describes the interfaces that provide access to the document-level components of an XPS OM.

This topic describes the interfaces that provide access to the document-level components of an XPS OM.

Interface name Logical child interfaces Description
IXpsOMDocument IXpsOMPageReference Represents a single FixedDocument part and binds a collection of page references. IXpsOMPageReferenceCollection is the collection interface that is used to iterate through the IXpsOMPageReference interfaces in a document.
IXpsOMDocumentStructureResource None Represents the DocumentStructure part.

Code Examples

The code examples in this section illustrate how some of the document interfaces are used in a program.

Get the page references of a document

The following code example gets a pointer to the IXpsOMPageReferenceCollection that contains the list of IXpsOMPageReference interfaces for the document that is referenced by doc parameter.

    HRESULT                               hr = S_OK;


    IXpsOMPageReferenceCollection         *pages;
    IXpsOMPageReference                   *pageRef;
    IXpsOMPage                            *page;

    UINT32  numPageRefs = 0;
    UINT32  thisPageRef = 0;

    // get the doc contents
    hr = doc->GetPageReferences(&pages);
        
    // walk the collection of page references
    hr = pages->GetCount(&numPageRefs);
    thisPageRef = 0;
    while (thisPageRef < numPageRefs) {
        // get this page reference
        hr = pages->GetAt(thisPageRef, &pageRef);

        // get the page content of this page reference
        hr = pageRef->GetPage (&page);

        // use the page

        // free this page & page reference and go to next
        page->Release();
        pageRef->Release();
        thisPageRef++;
    }

    pages->Release();

Get the document structure of a document

The following code example gets the resource that contains the document structure.

    HRESULT                             hr = S_OK;
    
    IXpsOMDocumentStructureResource     *docStruct;
    IStream                             *docStructResStream;

    // doc is passed in as an argument
    // get the doc contents
    hr = doc->GetDocumentStructureResource(&docStruct);
   
    hr = docStruct->GetStream ( &docStructResStream );

    // access the document structure resource 
    //  contents by reading from the stream

    docStructResStream->Release();
    docStruct->Release();

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)

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

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