1

I use less which uses pdftotext to extract text from pdf files, by less my.pdf. In this way, some words' letters are separated by spaces from a pdf file.

CH APTE R 2 5        T E ST IN G WE B A P P LIC AT IO N S      540

Some claimed that Adobe Reader doesn't have problem with it. I don't have the program to verify that. But I am interested in knowing what software programs in Linux can extract the words correctly?

2

PDF and its big sister PostScript are languages used to create documents that reproduce the same output every time to any device: monitor, printer, printing press, etc. Because of that it allows the creator of the document to specify each characters properties individually. Without looking at your document I would only be guessing as to the reason why the creator separated the characters. The most common reason is kerning. It is where the space between the characters is adjusted.

You are lucky that the characters are actually in order. There is no reason why the creator can't rearrange the characters so they are completely out of order. Even though they look like words on the page, in your case they are not words in the PDF code.

2

pdf is typeset to produce a visual output, it's not strictly required to even contain text information. Imagine it as a printer's board with lead letters put into it. Every letter is a box with absolute position, size and style. So are all the images and so on. If you have a mathematical formula in it, you can see where the problem is: who said the text is linear? You have a jumble of glyphs, each positioned and sized however the original creator intended.

You have a possibility of getting some resemblance of true text out of it, because pdf is a stripped down (and upgraded/adjusted) version of postscript, and still has commands that "print" longer strings at a time (which are then displayed to the specified style with embedded fonts). This is what you get with pdftotext. Still, the newlines, whitespace and so on, can be confusing if the output from original application split it into words or letters to achieve desired visual appearance.

You are out of luck if the text was converted to bezier splines, or if the document was scanned. A lot of modern viewers have OCR capabilites so some rudimentary form of search and selection still works in them. But don't expect to get a well-formatted output - text extraction is mostly reverse-engineering.

A more structured document would be needed to handle this properly - something that contained both the semantic content, as well as fixed device-independent display capabilities. We don't have that. html is ill-suited for paged output and the oxps is not much better than pdf in that matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.