다음을 통해 공유


XPS OM 패키지 인터페이스

패키지 인터페이스는 XPS 문서 파일에 해당하는 XPS OM의 최상위 수준을 나타냅니다. 이러한 인터페이스에는 XPS OM을 XPS 문서 또는 스트림으로 직렬화하고 XPS 패키지를 역직렬화하여 프로그램이 문서의 내용에 액세스할 수 있도록 하는 XPS OM을 만드는 메서드가 포함되어 있습니다.

인터페이스 이름 논리적 자식 인터페이스 묘사
IXpsOMPackage
IXpsOMDocumentSequence
IXpsOMCoreProperties
XPS 문서를 포함하는 패키지에 해당하는 전체 XPS OM입니다.
IXpsOMPackageWriter
없음
패키지에 문서 페이지를 증분 serialization할 수 있습니다.
IXpsOMCoreProperties
없음
문서 메타데이터에 액세스합니다.

코드 예제

다음 코드 예제에서는 일부 패키지 인터페이스를 프로그램에서 사용하는 방법을 보여 줍니다. 달리 명시되지 않는 한 기울임꼴로 설정된 모든 항목은 매개 변수 이름입니다.

XPS OM으로 XPS 문서 읽기

파일 이름이 xpsDocumentFilename저장된 기존 XPS 문서에서 이 코드 예제에서는 xpsPackage참조되는 XPS OM을 만듭니다.

    HRESULT                 hr = S_OK;
    IXpsOMPackage           *xpsPackage;

    hr = xpsFactory->CreatePackageFromFile(
        xpsDocumentFilename,
        FALSE,
        &xpsPackage);

    // xpsPackage now contains a pointer to the IXpsOMPackage
    // object that has been populated with the contents
    // of the XPS document in xpsDocumentFilename.

XPS 문서 파일에 XPS OM 쓰기

다음 코드 예제에서는 xpsPackage참조되는 XPS OM을 작성합니다. 이 예제에서는 이름이 fileName저장된 파일에 XPS 문서를 만듭니다.

    HRESULT hr = S_OK;

    hr = xpsPackage->WriteToFile(
        xpsDocumentFilename,
        NULL,                    // LPSECURITY_ATTRIBUTES
        FILE_ATTRIBUTE_NORMAL,
        FALSE);                  // optimizeMarkupSize

XPS OM의 문서 시퀀스 액세스

다음 코드 예제에서는 xpsPackage나타내는 XPS OM의 문서 시퀀스를 포함하는 IXpsOMDocumentSequence 인터페이스에 대한 포인터를 가져옵니다.

    HRESULT                         hr = S_OK;
    IXpsOMDocumentSequence          *docSeq;
    IXpsOMDocumentCollection        *docs;

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

문서의 CoreProperties에 액세스

다음은 프로그램이 CoreProperties 부분의 내용에 액세스할 수 있도록 IXpsOMCoreProperties 인터페이스에 대한 포인터를 가져오는 코드 예제입니다. 예제에서 문서는 xpsPackage표시되는 XPS OM으로 읽은 것으로 간주됩니다.

    HRESULT                         hr = S_OK;
    IXpsOMCoreProperties            *coreProps;
    LPWSTR                          title;

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

    // get the title property 
    hr = coreProps->GetTitle(&title);

    // do something with the title property here...

    // free the string when finished with it
    CoTaskMemFree ( title );
    coreProps->Release();

IXpsOMPackageWriter 인터페이스 사용하는

XPS OM 탐색

IXpsOMDocumentSequence 인터페이스

IXpsOMPackage 인터페이스

IXpsOMPackageWriter 인터페이스

IXpsOMCoreProperties 인터페이스