如何使用Java阅读PDF文件? [英] How to read PDF files using Java?

查看:149
本文介绍了如何使用Java阅读PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java从PDF文件中读取一些文本数据。请帮我这样做。

I want to read some text data from a PDF file using Java. Please help me to do this.

感谢任何帮助。

推荐答案

PDFBox 是我为此目的找到的最好的图书馆,它是全面的,如果你只是做基本的话,它真的很容易使用文本提取。可以在此处找到示例。

PDFBox is the best library I've found for this purpose, it's comprehensive and really quite easy to use if you're just doing basic text extraction. Examples can be found here.

它在页面上解释它,但要注意的一点是,使用setStartPage()和setEndPage()时的开始和结束索引都是两者。我第一次跳过了那个解释,然后我花了一段时间才意识到为什么每次通话都会得到多个页面!

It explains it on the page, but one thing to watch out for is that the start and end indexes when using setStartPage() and setEndPage() are both inclusive. I skipped over that explanation first time round and then it took me a while to realise why I was getting more than one page back with each call!

Itext 是另一个也适用于C#的替代方案,尽管我个人从未使用它。它比PDFBox更低级,所以如果您只需要基本文本提取,则不太适合这项工作。

Itext is another alternative that also works with C#, though I've personally never used it. It's more low level than PDFBox, so less suited to the job if all you need is basic text extraction.

这篇关于如何使用Java阅读PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆