3 ms·
It is not the case that treatment of spaces is completely wild and ad hoc. PDF can, and frequently does, contain the text itself along with the display of said
by Mediterraneo10 5y ago
It is not the case that treatment of spaces is completely wild and ad hoc. PDF can, and frequently does, contain the text itself along with the display of said text. This is why applications like pdftotext can often give you correct plaintext output.
OCR applications are able to make PDFs from scanned images accessible and searchable (and with the right spaces) precisely because they embed their output into that layer of the PDF meant for the text itself, not its presentation.
- aardvark179 5y agoActually what OCR programs do is a very clever hack. PDF is mostly just a way to describe how to render pages, and just like with any rendering frame work that can involve a bitmap, a set of stroke and fill commands, or some text rendering. A scanned document obviously is just a huge bitmap, but if you can identify the text, and can define a font that doesn’t draw anything, then you can add instructions to the PDF to render that text in that font and as long as you can specify character positions everything will line up nicely. If you are generating a PDF with text you can render a string with spaces and let the glyph layout sort it out, or render individual characters, or draw those characters by hand and use the invisible font trick (because your font is not licensed for embedding). It’s not that you’re using different conceptual layers of the PDF, you’re just choosing how to render your content.