Package org.apache.tika.parser.ocrencode
Class EncodeOCRParser
java.lang.Object
org.apache.tika.parser.AbstractExternalProcessParser
org.apache.tika.parser.ocrencode.EncodeOCRParser
- All Implemented Interfaces:
Serializable,Initializable,SelfConfiguring,Parser
Parser that base64-encodes image content instead of performing OCR
text extraction. This is useful when you need to preserve the original
image data in the parsed output for downstream processing by an
external service.
To configure this parser, pass an EncodeOCRConfig object
through the ParseContext, or configure it via tika-config.xml/json.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEncodeOCRParser(JsonConfig jsonConfig) Constructor for JSON configuration.EncodeOCRParser(EncodeOCRConfig config) -
Method Summary
Modifier and TypeMethodDescriptionvoidgetSupportedTypes(ParseContext context) Returns the set of media types supported by this parser when used with the given parse context.voidCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.voidparse(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext parseContext) Parses a document stream into a sequence of XHTML SAX events.Methods inherited from class org.apache.tika.parser.AbstractExternalProcessParser
register, release
-
Constructor Details
-
EncodeOCRParser
public EncodeOCRParser() -
EncodeOCRParser
-
EncodeOCRParser
Constructor for JSON configuration. Requires Jackson on the classpath.- Parameters:
jsonConfig- JSON configuration
-
-
Method Details
-
initialize
Description copied from interface:InitializableCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.- Specified by:
initializein interfaceInitializable- Throws:
TikaConfigException- if there is a problem with the configuration
-
checkInitialization
- Throws:
TikaConfigException
-
getSupportedTypes
Description copied from interface:ParserReturns the set of media types supported by this parser when used with the given parse context.- Specified by:
getSupportedTypesin interfaceParser- Parameters:
context- parse context- Returns:
- immutable set of media types
-
parse
public void parse(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext parseContext) throws IOException, SAXException, TikaException Description copied from interface:ParserParses a document stream into a sequence of XHTML SAX events. Fills in related document metadata in the given metadata object.The given document stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller.
Information about the parsing context can be passed in the context parameter. See the parser implementations for the kinds of context information they expect.
- Specified by:
parsein interfaceParserhandler- handler for the XHTML SAX events (output)metadata- document metadata (input and output)parseContext- parse context- Throws:
IOException- if the document stream could not be readSAXException- if the SAX events could not be processedTikaException- if the document could not be parsed
-
getDefaultConfig
-