English text extracted using itextpdf is not understandable

人盡茶涼 提交于 2019-12-01 22:36:28

If you want the text to be ordered based on its position on the page, you need to introduce a specific strategy, such as the LocationTextExtractionStrategy:

for (int i = 1; i <= reader.getNumberOfPages(); i++) {
    String str=PdfTextExtractor.getTextFromPage(reader, i, new LocationTextExtractionStrategy());
}

The LocationTextExtractionStrategy sometimes results in odd sentences, more specifically if the letters 'dance' on the page (the baseline of the glyphs differs for text on the same line). In that case, you can try the SimpleTextExtractionStrategy which will return the text in the order in which it appears in the PDF syntax content stream.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!