PdftoText | PHP and Xpdf

PHP TECHNOLOGY

Posted on 2015-02-27 01:14:29


In this post will explain how to convert the contents of pdf files into a text file and display it into the browser by using XPDF and PHP.

  First, you must download the file xpdf for windows, in here . 
Then extract the files “xpdf-3.02pl5-win32.zip” and change the folder name to “xpdf” then copy that folder into C drive so it will be C:xpdf.

 
Folder Xpdf

Folder Xpdf

After that, create a folder named “pdfToText” on your localhost htdocs and save a pdf file in it, in this case is “try.pdf“.

 
Folder try

Folder try

Then create a new document with the name and copy it “pdfToText.php” following text.

1
2
3
4
5
<?php
    $filename = "try.pdf";
    $content = shell_exec('C:\xpdf\bin32\pdftotext '.$filename.' -');
    echo $content;
?>
After that type http://localhost/pdfToText/pdfToText.php on your web browser and the results end up like this.

 
Final PDFtoText

Final PDFtoText

Ok that’s for the tutorial. Thanks for stopping by and read some posts on this website, hopefully this info is useful for every one who need it. See you in another tutorial and don’t forget to leave a comment for me. :D 
 Resource: http://loewyi.com/