# fpOpenSubFile()

This function opens a subfile as a stream, which can be used directly or passed to other KeyView interfaces.

## Syntax

    int (pascal *fpOpenSubFile) (
            void                  *pFile,
            KVExtractSubFileArg    extractArg,
            KVInputStream        **stream);

## Arguments

`pFile` | The identifier of the file. This is a file handle returned from fpOpenFile().
`extractArg` | A pointer to the structure KVExtractSubFileArg, which defines the subfile to extract. Before you initialize the KVExtractSubFileArg structure, use the macro `KVStructInit` to initialize the `KVStructHead` structure. For this call, you do not need to set either the `filePath` or `stream` members of this structure.
`stream` | A pointer that will receive the opened input stream.

## Returns

- If the subfile is opened, the return value is `KVERR_Success`.
- If the subfile is not opened, the return value is an error code.

## Discussion

After the file is extracted, call fpCloseSubFile() to free the resources used for the stream.

You cannot use the reader `pdf2sr` (see Use the pdf2sr Reader) when using this function to extract files to a stream.

## Example

    KVExtractSubFileArgRec extractArg = {0};
    KVInputStream stream = NULL;

    KVStructInit(&extractArg);
    extractArg.index = index;

    error = extractInterface->fpOpenSubFile(pFile, &extractArg, &stream);
    if (error)
    {
        /* Handle error here */
    }
    else
    {
        /* Use stream here */

        extractInterface->fpCloseSubFile(stream);
    }

_FT_HTML5_bannerTitle.htm