The set of the supported features depends on the document format. GroupDocs.Parser provides the functionality to check if feature supported for the document. getFeatures property is used for this purposes.
The 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 getFeatures 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
try(Parserparser=newParser(Constants.SampleZip)){// Check if text extraction is supported for the document
if(!parser.getFeatures().isText()){System.out.println("Text extraction isn't supported");return;}// Extract a text from the document
try(TextReaderreader=parser.getText()){System.out.println(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
try(Parserparser=newParser(Constants.SampleZip)){// Extract a text into the reader
try(TextReaderreader=parser.getText()){// Print a text from the document
// If text extraction isn't supported, a reader is null
System.out.println(reader==null?"Text extraction isn't supported":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 getFeatures 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: