有没有办法在Java中识别出PDF是否为图像PDF?

huangapple 未分类评论41阅读模式
英文:

Is there a way to identify whether a PDF is an image PDF in Java?

问题

我正在使用Java将PDF转换为抓取一些数据。我正在使用Tesseract来抓取图像PDF,使用PDFBox来抓取非图像PDF。通常我们可以通过从PDF中选择文本来检查PDF是否为图像,如果无法从PDF中选中文本,则为图像PDF。
我想知道在Java中是否有一种方法可以判断PDF是否为图像PDF还是非图像PDF?

英文:

I'm converting PDF to scrape some data using java. I'm using Tesseract to scrape image PDFs and PDFBox to scrape non-image PDFs. Normally we can check whether PDF is an image or not by selecting text from PDF, if you are unable to highlight text from PDF then it is image PDF.
I want to know is there a way in java to find out whether PDF is an image PDF or non-image PDF?

答案1

得分: 0

你可以使用PDFBox从PDF中提取文本。如果文本不多,或者提取出的文本是无意义的,那么很可能是一个图像PDF。

英文:

You can use PDFBox to pull out the text from PDF. If there isn't much text, or the retrieved text is gibberish, it's more likely an image PDF.

huangapple
  • 本文由 发表于 2020年7月24日 20:06:08
  • 转载请务必保留本文链接:https://java.coder-hub.com/63073221.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定