Share via


IXpsOMDocument インターフェイスの操作

このトピックでは、XPS OM のドキュメント レベルのコンポーネントへのアクセスを提供するインターフェイスについて説明します。

インターフェイス名 論理子インターフェイス Description
IXpsOMDocument
IXpsOMPageReference
単一の FixedDocument パーツを表し、ページ参照のコレクションをバインドします。
IXpsOMPageReferenceCollection は、ドキュメント内の IXpsOMPageReference インターフェイスを反復処理するために使用されるコレクション インターフェイスです。
IXpsOMDocumentStructureResource
なし
DocumentStructure パーツを表します。

コード例

このセクションのコード例は、一部のドキュメント インターフェイスがプログラムでどのように使用されるかを示しています。

ドキュメントのページ参照を取得する

次のコード例では、doc パラメーターによって参照されるドキュメントの IXpsOMPageReference インターフェイスの一覧を含む IXpsOMPageReferenceCollection へのポインターを取得します。

    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();

ドキュメントのドキュメント構造を取得する

次のコード例では、ドキュメント構造を含むリソースを取得します。

    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();