Detect if a PDF is created from a scanned document using OCR [pdfbox]

折月煮酒 提交于 2019-12-23 05:27:33

问题


I would like to know if a PDF was created from a scanned document using OCR.

To make the text from the scanned document selectable, I guess the same text is written using a transparent color, a special font, ...

I'm using pdfbox and I looked at the font, the color, and many other properties and I didn't find anything special.


回答1:


In my case the text rendering mode was set to "Neither fill nor stroke text".

pdfbox code:

getGraphicsState().getTextState().getRenderingMode() == PDTextState.RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT



回答2:


In most cases, the original image is still present, and the OCRd text is invisible underneath.

So, one possibility would be finding out whether there is a picture covering all the area with text.

Another possibility would be looking at the fonts and make some smart decisions based on them



来源:https://stackoverflow.com/questions/24184308/detect-if-a-pdf-is-created-from-a-scanned-document-using-ocr-pdfbox

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