使用 IXpsOMDocumentSequence 接口

本主题介绍如何使用提供对 FixedDocumentSequence 的访问的接口,FixedDocumentSequence 是 XPS OM 中文档层次结构的顶层。

接口名称 逻辑子接口 说明
IXpsOMDocumentSequence
IXpsOMDocument
将一组 FixedDocuments 分组到有序列表中。
IXpsOMDocumentCollection

XPS 文档序列中的 FixedDocuments 集合。

代码示例

下面的代码示例获取指向 IXpsOMDocumentSequence 接口的指针,该接口包含由 xpsPackage 表示的 XPS OM 的文档序列。 然后,该示例枚举集合中的文档。

    HRESULT                         hr = S_OK;

    IXpsOMDocumentSequence          *docSeq;
    IXpsOMDocumentCollection        *docs;
    IXpsOMDocument                  *doc;

    UINT32  numDocs = 0;
    UINT32  thisDoc = 0;

    // get the fixed document sequence of the package
    hr = xpsPackage->GetDocumentSequence(&docSeq);

    // get the collection of fixed documents in 
    //  the fixed document sequence
    hr = docSeq->GetDocuments(&docs);

    // walk the collection of documents;
    hr = docs->GetCount(&numDocs);
    thisDoc = 0;
    while (thisDoc < numDocs) {
        hr = docs->GetAt(thisDoc, &doc);
 
        // use this doc for something

        // release this doc and then go to the next one
        doc->Release();
        thisDoc++;
    }
    // release the document collection and
    // the document sequence
    docs->Release();
    docSeq->Release();