IXpsOMDocument 인터페이스 작업
이 항목에서는 XPS OM의 문서 수준 구성 요소에 대한 액세스를 제공하는 인터페이스에 대해 설명합니다.
인터페이스 이름 | 논리 자식 인터페이스 | 설명 |
---|---|---|
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();