Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting PDF to string [closed]

How read PDF file and put content into string? Using PHP language.

like image 436
lolalola Avatar asked Jan 24 '11 09:01

lolalola


People also ask

How do I convert PDF to Word without messing?

Step 1 Download and install Adobe Acrobat on your computer from the official website of Adobe. Step 2 Open a PDF file in Adobe Acrobat that you want to convert into Word without changing the format. Step 3 From the menu click on File and Export. Step 4 Now choose "Microsoft Word Document" as the text format.


1 Answers

You could use something like pdftotext which comes with the Xpdf package on linux. The popen command can then be used to pipe the output of pdftotext into a string:

$mystring = "";
$fd = popen("/usr/bin/pdftotext blah.pdf","r");
if ($fd) {
    while (($myline = fgets($fd)) !== false) {
        $mystring .= $myline;
    }
}
like image 199
Matthew Smith Avatar answered Sep 20 '22 06:09

Matthew Smith