Access a Subfile without Extracting the Entire File

Some operations do not require all of the data contained within a subfile. For example, format detection can often be performed using only the beginning and end of a file, without needing to extract the entire file to disk or memory. When filtering, you might process part of a file before deciding not to continue.

Extracting only part of a subfile can take less time and improve the performance of your application. For this reason, you can open a subfile as an input stream, which you can pass to another KeyView context or use in your own code.

NOTE: You cannot use the reader pdf2sr when extracting files to a stream.

To open a subfile as an input stream

  1. Follow the instructions for extracting subfiles as far as calling fpGetMainFileInfo() to ascertain that the main file is a container.

  2. Open the subfile by calling fpOpenSubFile().

  3. Use the returned stream as required. For example, you can pass the KVInputStream to fpGetDocInfoStream() or pass it to fpOpenStream() and then filter the subfile.

    NOTE: Input streams derived from the same context are not thread-safe so Micro Focus strongly recommends that streams are used only on the thread on which they were created. However, to pass a KVInputStream back into KeyView, you must create a new context using fpInit() or fpInitWithLicenseData().

    If a problem is encountered when using the stream, you can call fpGetExtractStatus() to establish the cause of the problem.

  4. Free resources using fpCloseSubFile() and fpFreeStruct().