So many of these problems have been solved by mozilla pdf.js together with its viewer implementation: https://mozilla.github.io/pdf.js/ .
A good PDF reader makes the problems easier to deal with, but does not solve the underlying issue. The PDF itself is still flawed, even if pdf.js interprets it perfectly, which is still a problem for non-pdf.js viewers and tasks where "viewing" isn't the primary goal.
PDF to Text, a challenging problem
81–90 of 206 posts
Re: PDF to Text, a challenging problem
#82Yeah, getting text - even structured text - out of PDFs is no picnic. Scraping a table out of an HTML document is often straightforward even on sites that use the "everything's a " (anti-)pattern, and especially on sites that use more semantically useful elements, like . Not so PDFs. I'm far from an expert on the format, so maybe there is some semantic support in there, but I've seen plenty of PDFs where tables are s…
Re: PDF to Text, a challenging problem
#83Re: PDF to Text, a challenging problem
#84Maybe it's time for new document formats and browsers that neatly separate content, presentation and UI layers? PDF and HTML are 20+ years old and it's often difficult to extract information from either let alone author a browser.
Re: PDF to Text, a challenging problem
#85"PDF to Text" is a bit simplified IMO. There's actually a few class of problems within this category: 1. reliable OCR from documents (to index for search, feed into a vector DB, etc) 2. structured data extraction (pull out targeted values) 3. end-to-end document pipelines (e.g. automate mortgage applications) Marginalia needs to solve problem #1 (OCR), which is luckily getting commoditized by the day thanks to models…
This is hard because:
1. Unlike a business workflow which often only deals with a few specific kinds of documents, you never know what the user is going to get. You're making an abstract PDF reader, not an app that can process court documents in bankruptcy cases in Delaware.
2. You don't just need the text (like in traditional OCR), you need to recognize tables, page headers and footers, footnotes, headings, mathematics etc.
3. Because this is for human consumption, you want to minimize errors as much as possible, which means not using OCR when not needed, and relying on the underlying text embedded within the PDF while still extracting semantics. This means you essentially need two different paths, when the PDF only consists of images and when there are content streams you can get some information from.
3.1. But the content streams may contain different text from what's actually on the page, e.g. white-on-white text to hide information the user isn't supposed to see, or diacritics emulation with commands that manually draw acute accents instead of using proper unicode diacritics (LaTeX works that way).
4. You're likely running as a local app on the user's (possibly very underpowered) device, and likely don't have an associated server and subscription, so you can't use any cloud AI models.
5. You need to support forms. Since the user is using accessibility software, presumably they can't print and use a pen, so you need to handle the ones meant for printing too, not just the nice, spec-compatible ones.
This is very much an open problem and is not even remotely close to being solved. People have been taking stabs at it for years, but all current solutions suck in some way, and there's no single one that solves all 5 points correctly.
Re: PDF to Text, a challenging problem
#86Have any of you ever thought to yourself, this is new and interesting, and then vaguely remembered that you spent months or years becoming an expert at it earlier in life but entirely forgot it? And in fact large chunks of the very interesting things you've done just completely flew out of your mind long ago, to the point where you feel absolutely new at life, like you've accomplished relatively nothing, until someth…
Re: PDF to Text, a challenging problem
#87Re: PDF to Text, a challenging problem
#88Have any of you ever thought to yourself, this is new and interesting, and then vaguely remembered that you spent months or years becoming an expert at it earlier in life but entirely forgot it? And in fact large chunks of the very interesting things you've done just completely flew out of your mind long ago, to the point where you feel absolutely new at life, like you've accomplished relatively nothing, until someth…
No different than a fire ant whose leaf got knocked over by the wind and it moved on to the next.
Re: PDF to Text, a challenging problem
#89Re: PDF to Text, a challenging problem
#90Earlier quoted context omitted.
I don't think so, pdf.js is able to render a pdf content. Which is different from extracting "text". Text in PDF can be encoded in many ways, in an actual image, in shapes (think, segments, quadratic bezier curves...), or in an XML format (really easy to process). PDF viewers are able to render text, like a printer would work, processing command to show pixels on the screen at the end. But often, paragraph, text layo…
Correct me if im wrong, but pdf.js actually has a lot of methods to manipulate PDFs, no?
The purpose of my original comment was to simply say: there’s an existing implementation so if you’re building a pdf file viewer/editor, and you need inspiration, have a look. One of the reasons why mozilla is doing this is to be a reference implementation. I’m not sure why people are upset with this. Though, I could have explained it better.