File Content Extraction 25.1
Filter SDK .NET Programming Guide

# Partial Filtering

In some cases you might not want to filter all of the text from a file or stream. You might prefer to stop filtering, saving time and resources, as soon as you find the information that you require.

You can read filtered text from a stream provided by the `Text()` method on your `Document` object. This allows you to stop processing before the end of the stream. File Content Extraction only processes as much of the document as it needs to output the text you read.

Copy

    using (Document myDoc = session.Open(inputFilePathOrStream))
    {
        try
        {
            using (FileStream fs = File.Create(outputFilePath))
            using (StreamWriter sw = new StreamWriter(fs))
            using (DocumentStreamReader dsr = myDoc.Text())
            {
                while (!dsr.EndOfStream)
                {
                    // Read filtered text one line at a time
                    var filterOutput = dsr.ReadLine();

                    Console.WriteLine(filterOutput);
                    sw.WriteLine(filterOutput);

                    // Here the program can check to see if a certain
                    // condition is met, and stop filtering
                }
            }
        }
        catch (KeyViewException e)
        {
            Console.WriteLine($"{e.Message}");
        }
    }

Copyright 1997-2024 Open Text
Version 25.1 | Last updated January 2025

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 25.1

Topic Title: Partial Filtering