@Override
    public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
                      ParseContext parseContext) throws IOException, SAXException, TikaException {

        TesseractOCRConfig userConfig = parseContext.get(TesseractOCRConfig.class);
        TesseractOCRConfig config = defaultConfig;
        if (userConfig != null) {
            config = defaultConfig.cloneAndUpdate(userConfig);
        }
        // If Tesseract is not on the path with the current config, do not try to run OCR
        // getSupportedTypes shouldn't have listed us as handling it, so this should only
        //  occur if someone directly calls this parser, not via DefaultParser or similar
        if (!hasTesseract || (config != null && config.isSkipOcr())) {
            return;
        }

        //if you haven't checked yet, and a per file config requests imagemagick
        //and if the default is not to use image processing
        if (! HAS_CHECKED_FOR_IMAGE_MAGICK && config.isEnableImagePreprocessing()) {
            hasImageMagick = hasImageMagick();
        }

        try (TemporaryResources tmp = new TemporaryResources()) {
            TikaInputStream tikaStream = TikaInputStream.get(stream, tmp, metadata);

            //trigger the spooling to a tmp file if the stream wasn't
            //already a TikaInputStream that contained a file
            tikaStream.getPath();
            //this is the text output file name specified on the tesseract
            //commandline.  The actual output file name will have a suffix added.
            File tmpOCROutputFile = tmp.createTemporaryFile();
            ContentHandler baseHandler = getContentHandler(config.isInlineContent(), handler, metadata, parseContext);
            XHTMLContentHandler xhtml = new XHTMLContentHandler(baseHandler, metadata);
            xhtml.startDocument();
            parse(tikaStream, tmpOCROutputFile, xhtml, metadata, parseContext, config);
            xhtml.endDocument();
        }
    }
TesseractOCRParser powered by tesseract-ocr engine. To enable this parser,
create a {@link TesseractOCRConfig} object and pass it through a
ParseContext. Tesseract-ocr must be installed and on system path or the path
to its root folder must be provided:
<p>
TesseractOCRConfig config = new TesseractOCRConfig();<br>
//Needed if tesseract is not on system path<br>
config.setTesseractPath(tesseractFolder);<br>
parseContext.set(TesseractOCRConfig.class, config);<br>
</p>
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-ocr-module/src/main/java/org/apache/tika/parser/ocr/TesseractOCRParser.java