private String extractTextWithTika(byte[] textBytes, Metadata metadata) throws TikaException, SAXException, IOException {
AutoDetectParser parser = new AutoDetectParser(new MimeTypes());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(baos, "UTF-8");
ContentHandler handler = new BodyContentHandler(writer);
ParseContext context = new ParseContext();
context.set(PDFParserConfig.class, new LumifyParserConfig());
parser.parse(new ByteArrayInputStream(textBytes), handler, metadata, context);
return IOUtils.toString(baos.toByteArray(), "UTF-8");
}