从pdf

时间:2015-12-08 11:01:24

标签: pdf itext pdfbox pdf2htmlex

我想知道pdf页面中所有单词的位置。我一直试图在网上找到一些但却无法找到的东西。任何人都可以帮助我使用哪个库(最好是在java平台上)?

2 个答案:

答案 0 :(得分:0)

看一下本教程:http://www.luigimicco.altervista.org/doku.php/en/doc/pdf_structure

基本上,使用PDFBox,您可以使用

链接到PDFContent
InputStream is = yourPDFDocument.getDocumentCatalog().getPages().get(yourPage).getContents();

然后,搜索您正在寻找的 X Y Td 行。

真的确定有一种更简单的方法可以做到这一点,但由于我在内容流中为项目工作了很多,所以我只知道这种方式。 /> 在PDFBox's javaDocs中搜索以获取更多详细信息!

我希望这会对你有所帮助:)。

答案 1 :(得分:0)

您可以使用 Textricator,但遗憾的是文档没有维护,因此很难让它更有趣的方面发挥作用。但是,要仅查看文本位置,您可以使用简单文本模式。

./textricator.bat text --pages=2 xxx.pdf

# output is a long list of CSV properties for the document, including the OCR read text and the x,y coordinates of it.