Created
June 13, 2019 06:14
-
-
Save kenmlee/18b589b6d0b40ccf5f78f4abcaa91474 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void extractImageText(XHTMLContentHandler xhtml, HWPFDocument document) { | |
if (Config.inst().getProp(ConfigBool.ENABLE_IMAGE_OCR)) { | |
TikaImageHelper helper = new TikaImageHelper(metadata); | |
try { | |
List<Picture> pictures2 = document.getPicturesTable().getAllPictures(); | |
for (Picture picture : pictures2) { | |
ByteArrayInputStream imageData = new ByteArrayInputStream( | |
picture.getContent()); | |
helper.addImage(ImageIO.read(imageData)); | |
} | |
// TODO: find out page number | |
helper.addTextToHandler(xhtml); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
if (helper != null) { | |
helper.close(); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment