|The stupid question is the question not asked|
Extracting text from PDF. No reallyby clinton (Priest)
|on Mar 28, 2008 at 11:56 UTC||Need Help??|
clinton has asked for the wisdom of the Perl Monks concerning the following question:
Before you copy-paste a Super Search response, hear me out.
This question has been asked many times : how do you extract text from a PDF document? The answer is always "use CAM::PDF". And believe me, I've tried.
I have never yet seen it produce anything usable. Instead, it produces a string of meaningless characters. I've tried using the included utility getpdftext.pl on various PDFs, including a very simple one created from Open Office, and the result is always meaningless jumble.
Take this PDF for example. It is PDF version 1.3, not encrypted and not optimized. getpdftext.pl produces this:
pdftotext -layout from xpdf produces this:
... clearly dropping the first character on several lines. (It does this in -raw mode as well). And yet xpdf and evince both display this PDF correctly.
So where to from here? I need something that works on linux, preferably OOS, preferably Perl. The other PDF modules on CPAN (such as PDF::API2, PDF::Reuse and PDFLib seem to be intended for generating new PDFs, not extracting the contained text).
So what else can I try? Any suggestions?