note 77097 added to ref.pdf
| From: | SamfromdogmaConsult dot de at osu1 dot php dot net | Date: | Wed, 15 Aug 2007 09:00:20 +0000 |
| Subject: | note 77097 added to ref.pdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129489@lists.php.net to get a copy of this message | ||
I seriously tried to get PDF parsing to work to use it in the indexing for fulltext search for a
document management. But none of the pdf2text functions below worked for my test cases (among them
an openoffice generated pdf file and a file generated by fpdf).
But I found a REALLY WORKING SOLUTION! On linux systems, install the XPDF package. It comes with a
tool called pdftotext. Use php code similar to the following to get the text content of your pdf
files:
<?
$file = "test.pdf";
$outpath = preg_replace("/\.pdf$/", "", $file).".txt";
system("pdftotext ".escapeshellcmd($file), $ret);
if ($ret == 0)
{
$value = file_get_contents($outpath);
unlink($outpath);
print $value;
}
if ($ret == 127)
print "Could not find pdftotext tool.";
if ($ret == 1)
print "Could not find pdf file.";
?>
The solution works on all test cases and is much more powerful than any of the previous pure php
functions posted here, although only available on linux.
----
Server IP: 212.124.37.9
Probable Submitter: 84.58.157.64
----
Manual Page -- http://www.php.net/manual/en/ref.pdf.php
Edit -- https://master.php.net/note/edit/77097
Del: integrated -- https://master.php.net/note/delete/77097/integrated
Del: useless -- https://master.php.net/note/delete/77097/useless
Del: bad code -- https://master.php.net/note/delete/77097/bad+code
Del: spam -- https://master.php.net/note/delete/77097/spam
Del: non-english -- https://master.php.net/note/delete/77097/non-english
Del: in docs -- https://master.php.net/note/delete/77097/in+docs
Del: other reasons-- https://master.php.net/note/delete/77097
Reject -- https://master.php.net/note/reject/77097
Search -- https://master.php.net/manage/user-notes.php