Get supported features

The set of the supported features depends on the document format. GroupDocs.Parser provides the functionality to check if feature supported for the document. Features property is used for this purposes.

Features class has the following members:

MemberDescription
bool IsFeatureSupported(string featureName)Returns the value that indicates whether the feature is supported.
TextThe value that indicates whether text extraction is supported.
TextPageThe value that indicates whether text page extraction is supported.
FormattedTextThe value that indicates whether formatted text extraction is supported.
FormattedTextPageThe value that indicates whether formatted text page extraction is supported.
SearchThe value that indicates whether text search is supported.
HighlightThe value that indicates whether highlight extraction is supported.
StructureThe value that indicates whether text structure extraction is supported.
TocThe value that indicates whether table of contents extraction is supported.
ContainerThe value that indicates whether container extraction is supported.
MetadataThe value that indicates whether metadata extraction is supported.
TextAreasThe value that indicates whether text areas extraction is supported.
ImagesThe value that indicates whether images extraction is supported.
ParseByTemplateThe value that indicates whether parsing by template is supported.
ParseFormThe value that indicates whether form parsing is supported.

Here are the steps for check if feature is supported:

  • Instantiate Parser object for the initial document;
  • Call corresponding property of Feature property to check if the feature is supported.

The following example shows how to check if text extraction feature is supported:

// Create an instance of Parser class
using(Parser parser = new Parser("doc.zip"))
{
    // Check if text extraction is supported for the document
    if(!parser.Features.Text)
    {
        Console.WriteLine("Text extraction isn't supported");
        return;
    }

    // Extract a text from the document
    using(TextReader reader = parser.GetText())
    {
        Console.WriteLine(reader.ReadToEnd());
    }
}

If the feature isn’t supported, the method returns null instead of the value. So if checking of Features properties is omitted, result is checked for null:

// Create an instance of Parser class
using(Parser parser = new Parser("doc.zip"))
{
    // Extract a text from the document 
    using(TextReader reader = parser.GetText())
    {
        // Check if reader isn't null
        if(reader == null)
        {
            Console.WriteLine("Text extraction isn't supported");
        }
        else
        {
            Console.WriteLine(reader.ReadToEnd());
        }
    }
}

This example prints “Text extraction isn’t supported” because there is no text in zip-archive.

Some operations may consume significant time. So it’s not optimal to call the method to just check the support for the feature. For this purpose Features property is used.

More resources

Advanced usage topics

To learn more about document data extraction features and get familiar how to extract text, images, forms and more, please refer to the advanced usage section.

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document parser App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.