ILogger interface is used to receive the information about errors, warnings and events which occur while data extraction. ILogger interface has the following members:
The following example shows how to receive the information via ILogger interface.
try{// Create an instance of Logger class
Loggerlogger=newLogger();// Create an instance of Parser class with the parser settings
try(Parserparser=newParser(Constants.SamplePassword,null,newParserSettings(logger))){// Check if text extraction is supported
if(!parser.getFeatures().isText()){System.out.println("Text extraction isn't supported.");return;}// Print the document text
try(TextReaderreader=parser.getText()){System.out.println(reader.readToEnd());}}}catch(InvalidPasswordException|IOExceptionex){;// Ignore the exception
}classLoggerimplementsILogger{publicvoiderror(Stringmessage,Exceptionexception){// Print error message
System.out.println("Error: "+message);}publicvoidtrace(Stringmessage){// Print event message
System.out.println("Event: "+message);}publicvoidwarning(Stringmessage){// Print warning message
System.out.println("Warning: "+message);}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: