File Content Extraction 26.2
Filter SDK C Programming Guide

# Process Subfiles

To filter all files in a container file, you can open the container and then open its subfiles as KVDocument objects by using the File Extraction API. After you open a subfile as a KVDocument, you can call Filter API methods to filter the data.

In the following example, we open each subfile as a document, and filter some text from it.

Copy

    KVMainFileInfo mainFileInfo = NULL;
    KVErrorCode error = extract.fpGetMainFileInfo(container, &mainFileInfo);
    if (error == KVError_Success)
    {
        for (int ii = 0; ii < mainFileInfo->numSubFiles; ++ii)
        {
            KVOpenDocumentFromSubFileArgRec openArg;
            KVStructInit(&openArg);
            openArg.index = ii;

            KVDocument subFileDocument = NULL;
            KVSubFileExtractInfo postExtractInfo = NULL;
            error = extract.fpOpenDocumentFromSubFile(container, &openArg, &subFileDocument, &postExtractInfo);

            if (error == KVError_Success)
            {
                if (subFileDocument)
                {
                    KVFilterOutput output;
                    error = filter.fpFilter(subFileDocument, &output);

                    if (error == KVError_Success)
                    {
                        // [Add your code to handle text]

                        filter.fpFreeFilterOutput(session, &output);
                    }
                    // [Add your code to continue processing document]

                    filter.fpCloseDocument(subFileDocument);
                }

                extract.fpFreeStruct(container, postExtractInfo);
            }
        }
        extract.fpFreeStruct(container, mainFileInfo);
    }

## Extract Subfiles

In some cases, you might need to access the subfiles directly, for example to archive the subfiles or process them using a different tool. In this case, you can extract the subfiles to a file or a stream by using the File Extraction API. After you extract a subfile, you can call Filter API methods to process them, in the same way as for any other file.

To extract subfiles

1. Call fpGetExtractInterface() and pass in the session that you initialized using fpInit(), and a pointer to a KVExtractInterface structure.

2. Declare the input stream or file name in the KVOpenFileArg structure.

3. Open the source file by calling fpOpenFile() and passing the `KVOpenFileArg` structure. This call defines the parameters necessary to open a file for extraction.

4. Determine whether the source file is a container file (that is, whether it contains subfiles) by calling fpGetMainFileInfo().

5. If the call to `fpGetMainFileInfo()` determined that the source file is a container file, proceed to step 6; otherwise, filter the file.

6. Determine whether the subfile is itself a container (that is, whether it contains subfiles) by calling fpGetSubFileInfo().

7. Extract the subfile by calling fpExtractSubFile().

8. If the call to `fpGetSubFileInfo()` determined that the subfile is a container file, repeat step 2 through step 7 until all subfiles are extracted and the lowest level of subfiles is reached; otherwise, filter the file.

NOTE: Some options change the order in which subfiles are retrieved, such as enabling the root node. However, for each combination of options, the subfile order is consistent across multiple runs.

Copyright 1997-2026 Open Text
Version 26.2 | Last updated April 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.2

Topic Title: Process Subfiles