1

Possible Duplicate:
Read pdf files with php

Can you read PDF files by using PHP code?

Community
  • 1
  • 1
Dhinesh.B
  • 461
  • 4
  • 10
  • 20
  • What do you want to do with the PDF? Are you trying to read textual data from it, or just combine several PDFs? – Rowland Shaw Mar 03 '11 at 12:32
  • Please use the Search function before asking. This has been answered numerous times before: http://stackoverflow.com/search?q=read+pdf+files+php – Gordon Mar 03 '11 at 12:41

3 Answers3

3

To read PDF files, you will need to install the XPDF ( http://www.foolabs.com/xpdf/about.html ) package, which includes "pdftotext." Once you have XPDF/pdftotext installed, you run the following PHP statement to get the PDF text:

$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -'); //dash at the end to output content
Mohammad Efazati
  • 4,812
  • 2
  • 35
  • 50
2

You would have to use a extension like

http://www.pdflib.com/products/pdflib-family/

or

http://framework.zend.com/manual/en/zend.pdf.html

Tobias Schittkowski
  • 2,221
  • 2
  • 16
  • 25
  • actually i'm trying to form a tag cloud, so in tag cloud i tried by text files it working fine but when i was tried with pdf it's not working properly... – Dhinesh.B Mar 03 '11 at 12:36
2

Yes, you can. Either install a command line script that can convert PDFs to text and execute this in PHP

$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -'); //dash at the end to output content

(source)

... or write a PHP function like this.

slhck
  • 36,575
  • 28
  • 148
  • 201
  • for using(shell_exec) the code above u gave, is there any supporting file is needed or this single code convert pdf to text files.. – Dhinesh.B Mar 03 '11 at 12:42
  • 1
    You need to install the command line script that I referred to in my first link. – slhck Mar 03 '11 at 12:44
  • oh k thank u very much its working fine... is there any other way or code to read php files.. – Dhinesh.B Mar 03 '11 at 12:47
  • If it's working, accept or upvote the answer so that the question is closed. What do you mean by "other code to read php files"? – slhck Mar 03 '11 at 12:48