File Content Extraction 26.1
Filter SDK C Programming Guide

# fpOpenDocumentFromSubFile()

This function opens a subfile as a KVDocument, which can be passed directly to other FilterSDK interface functions.

## Syntax

    KVErrorCode (pascal* fpOpenDocumentFromSubFile)(
        void* pFile,
        KVOpenDocumentFromSubFileArg openArg,
        KVDocument* ppDocument,
        KVSubFileExtractInfo* extractInfo
    );

## Arguments

`pFile` | The identifier of the file. This is a file handle returned from fpOpenFile().
`openArg` | A KVOpenDocumentFromSubFileArg structure. Use this structure to specify the subfile you want to extract, and how you want to extract it. Before you initialize the KVOpenDocumentFromSubFileArg structure, use the macro `KVStructInit` to initialize the KVStructHead structure.
`ppDocument` | A pointer to a `KVDocument`.
`extactInfo` | A pointer to a KVSubFileExtractInfo.

## Returns

If the subfile was opened as a document, the return value is `KVError_Success`.

If the subfile is an external link, the return value is `KVError_Success` and `ppDocument` points to the null pointer.

Otherwise the return value is an error code.

## Lifetime and Memory Management

If the functions return `KVError_Success`, you must clean up the objects pointed to by `ppDocument` and `extractInfo`.

If `ppDocument` does not point to the null pointer, when you have finished with the `KVDocument` that was returned in `*ppDocument`, you must call fpCloseDocument() to free the memory that was allocated by this function.

The Filter session must outlive the `KVDocument` created by this function. In other words, you must call fpCloseDocument() on the `KVDocument` before calling fpShutdown() on the Filter session (session) that was used to create it. You must call fpFreeStruct() to free `*extractInfo`.

## Discussion

Before opening the subfile, you must get the main file information by calling fpGetMainFileInfo().

If the subfile is an external link, the return value is `KVError_Success` and `ppDocument` points to the null pointer. KVSubFileExtractInfo contains information about the external link.

If you intend to recursively extract each subfile, you might want to consider using a recursion limit.

## Example

    KVOpenDocumentFromSubFileArgRec openArg;
    KVStructInit(&openArg);
    openArg.index = index;
    extractArg.extractionFlag = KVExtractionFlag_GetFormattedBody;
    KVDocument document = NULL;
    KVSubFileExtractInfo postExtractInfo = NULL;
    error = extractInterface->fpOpenDocumentFromSubFile(fileContext, &openArg, &document, &postExtractInfo);
    extractInterface->fpFreeStruct(postExtractInfo);
    filterInterface->fpCloseDocument(document);

Copyright 1997-2025 Open Text
Version 26.1 | Last updated January 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: File Content Extraction 26.1

Topic Title: fpOpenDocumentFromSubFile()