Tesseract: is it possible to change font output in OCRed pdf

evincefontsocrpdftesseract

Following up on how to OCR a pdf file and get the text stored within pdf? I have successfully produced OCRed pdf pages.

In Evince, however, the letters are not shown; by this I mean that I cannot see the characters, but I can select them, copy them and paste them elsewhere successfully. This does not seem to be a bug of Evince: https://bugzilla.redhat.com/show_bug.cgi?id=1364201

When initiating an OCR of a pdf page with pdfsandwich, tesseract produces a page that

contains a font which doesn't have any
usable glyphs (they named it GlyphLessFont). It has only .notdef and
.null replacements (the squares). Evince uses the .notdef glyph if there
is no glyph for the character. The reason that Okular highlight the text
is because it does it in the image not as a regular text as evince does.

pdftotext recognises the characters.

Now, the question is: can tesseract be told to use a different font?

Best Answer

You could customise this portion of the source code to your liking and change the font here. You will have to rebuild tesseract from source once you make the change.

Tesseract Github Renderer.h

Related Question