KeyView 24.1

# Filter in File or Stream Mode

To filter a file or stream

1. Instantiate a `Filter` object, providing your license key.

   - To instantiate the Filter object with the default output character set and filtering options:

         Filter objFilter = new Filter("YOUR_KEYVIEW_LICENSE");

   - To instantiate the Filter object with your chosen output character set and filtering options:

         Filter objFilter = new Filter("YOUR_KEYVIEW_LICENSE", Charset.KVCS_UTF8, 0);

     The filter flags provide instructions about how to process a file or stream. For example, you can specify whether to run filtering out-of-process (`FILTERFLAG_OUTOFPROCESS`), whether to log errors during filtering (`FILTERFLAG_OOPLOGON`), and whether to extract headers and footers from a document (`FILTERFLAG_HEADERFOOTERTAGS`).

     NOTE: Filter runs out of process by default. See The Filter Process Model for more information.

2. Set the location of the Filter libraries by setting the `FilterDirectory` property. These libraries are provided in the directory `PLATFORM\bin`, in the KeyView Filter SDK, where `PLATFORM` is the name of the platform. For example:

       objFilter.FilterDirectory = "C:\\KeyviewFilterSDK\\WINDOWS_X86_64\\bin";

3. Set the input source as either a file or input stream by calling the `SetInputSource` method.

       objFilter.SetInputSource(m_inFile);

4. Filter the file or stream by calling either the `FilterTo` or `DoFilterChunk` method. The `FilterTo` method extracts the data to a file or a stream. The `DoFilterChunk` method extracts one chunk of data from a file or a stream. It must be called repeatedly until the entire buffer is filtered.

   If filtering in file mode, use the following code:

          {
            objFilter.filterTo(m_extractDir + filename + m_extension);
          }

   If filtering in stream mode, use the following code:

           {
            outf = new File(m_extractDir + filename + m_extension);
            fos = new FileOutputStream(outf);
            objFilter.filterTo(fos);
            fos.close();
           }

5. Terminate the filtering session and free allocated system resources by calling the `ShutdownFilter()` method. This must be called within a `Finally` block.

       objFilter.ShutdownFilter();

Copyright 2016-2023 Open Text
Version 24.1 | Last updated December 2023

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: IDOL KeyView 24.1

Topic Title: Filter in File or Stream Mode