XPS OM 파트 인터페이스
이 항목에서는 XPS OM에서 XPS 문서 파트에 대한 액세스를 제공하는 인터페이스를 사용하는 방법을 설명합니다.
인터페이스 이름 | 논리 자식 인터페이스 | 설명 |
---|---|---|
IXpsOMPart |
IXpsOMDocumentSequence IXpsOMDocument IXpsOMPageReference IXpsOMCoreProperties IXpsOMResource |
문서 구조를 구성하는 문서 구성 요소입니다. |
IXpsOMResource IXpsOMPartResources |
IXpsOMFontResource IXpsOMImageResource IXpsOMColorProfileResource IXpsOMPrintTicketResource IXpsOMRemoteDictionaryResource IXpsOMDocumentStructureResource IXpsOMStoryFragmentsResource IXpsOMSignatureBlockResource |
페이지 또는 문서에서 사용하거나 참조하는 요소가 포함된 문서 구성 요소입니다. |
IXpsOMPartUriCollection |
없음 |
파트 URI의 컬렉션입니다. |
코드 예제
다음 코드 예제에서는 파트 인터페이스를 사용하여 XPS OM 콘텐츠에 액세스하는 방법에 대한 두 가지 예제를 보여 줍니다.
문서 파트의 이름 가져오기
다음 코드 예제에서는 문서 부분으로 이동 하 고 파트의 이름을 가져옵니다.
HRESULT hr = S_OK;
IXpsOMDocumentSequence *docSeq;
IXpsOMDocumentCollection *docs;
IXpsOMDocument *doc;
IXpsOMPageReferenceCollection *pages;
IXpsOMPageReference *pageRef;
IXpsOMPage *page;
IOpcPartUri *thisDocPartUri;
IOpcPartUri *thisPagePartUri;
UINT32 numDocs = 0;
UINT32 thisDoc = 0;
UINT32 numPageRefs = 0;
UINT32 thisPageRef = 0;
// package points to the IXpsOMPackage interface to walk.
// get the fixed document sequence of the package
hr = package->GetDocumentSequence(&docSeq);
// get the 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);
// get the part name (URI) of this document
hr = doc->GetPartName ( &thisDocPartUri );
// 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 part name (URI) of this page
hr = pageRef->GetPage (&page);
hr = page->GetPartName ( &thisPagePartUri );
// do something with the part name
thisPagePartUri->Release();
page->Release();
pageRef->Release();
thisPageRef++;
}
pages->Release();
thisDocPartUri->Release();
doc->Release();
thisDoc++;
}
docs->Release();
docSeq->Release();
이 페이지와 연결된 파트 리소스 가져오기
다음 코드 예제에서는 이 페이지에서 사용되는 다양한 리소스의 목록을 가져옵니다.
HRESULT hr = S_OK;
IXpsOMPartResources *resources;
IXpsOMColorProfileResourceCollection *colorProfileResources;
IXpsOMFontResourceCollection *fontResources;
IXpsOMImageResourceCollection *imageResources;
IXpsOMRemoteDictionaryResourceCollection *dictionaryResources;
// pageRef contains the current page reference
hr = pageRef->CollectPartResources ( &resources );
// Get pointers to each type of resource
hr = resources->GetColorProfileResources( &colorProfileResources );
hr = resources->GetFontResources( &fontResources );
hr = resources->GetImageResources( &imageResources );
hr = resources->GetRemoteDictionaryResources( &dictionaryResources );
// use resources
dictionaryResources->Release();
imageResources->Release();
fontResources->Release();
colorProfileResources->Release();
resources->Release();