title: Slowness in extracting scan PDF using Apache Tika + Tesseract
body: <p>From <a href="https://stackoverflow.com/questions/32354209/apache-tika-extract-scanned-pdf-files">Apache Tika extract scanned PDF files</a>, it works perfectly fine for scan document. But problem is, it is taking too much time as well as CPU utilization.</p>
  
  <p>In my case, <code>15 MB</code> file having <code>23 pages</code> takes around <code>~4.5 minute</code> which is too high. Please find below my working code,</p>
  
  <pre><code>Parser parser = new AutoDetectParser();
  BodyContentHandler handler = new BodyContentHandler(Integer.MAX_VALUE);
  
  TesseractOCRConfig config = new TesseractOCRConfig();
  PDFParserConfig pdfConfig = new PDFParserConfig();
  pdfConfig.setExtractInlineImages(true);
  
  ParseContext parseContext = new ParseContext();
  parseContext.set(TesseractOCRConfig.class, config);
  parseContext.set(PDFParserConfig.class, pdfConfig);
  //need to add this to make sure recursive parsing happens!
  parseContext.set(Parser.class, parser);
  
  Metadata metadata = new Metadata();
  parser.parse(inputStream, handler, metadata, parseContext);
  String content = handler.toString();
  </code></pre>
  
  <p>How can I make it more optimized/faster? Any suggestions?</p>