问题
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