Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This topic describes the interfaces that provide access to the document-level components of an XPS OM.
Interface name | Logical child interfaces | Description |
---|---|---|
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. |
||
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();