1

Possible Duplicate:
Read pdf files with php

Hi,

I have a bulk of pdf documents. I want to read that using php script. I searched a lot, but everyone is about creating pdf files. Here I dont want to create pdf file but I want to read it. Is there any way to read it php?

-Arun

Community
  • 1
  • 1
Arun SS
  • 1,791
  • 8
  • 29
  • 48

2 Answers2

0

You can easily read the contents of a PDF file using a command-line utility like Pdftotext which you can call through exec.

This is an example of what i mean, actually using system

system("pdftotext your.pdf /tmp/txtfile.txt");
$text = file_get_contents("/tmp/txtfile.txt");

EDIT

didn't know about the dash syntax - this is even better:

$content = shell_exec('pdftotext your.pdf -');

This does require pdftotext to be installed on your server though. On a CentOS server this would be:

yum install xpdf
robjmills
  • 18,438
  • 15
  • 77
  • 121
0

To just get the text from a PDF file, try these:
- http://davidwalsh.name/read-pdf-doc-file-php
- http://www.webcheatsheet.com/php/reading_clean_text_from_pdf.php (more in-depth)

For a more heavyweight solutions, have a look at:
- http://www.setasign.de/products/pdf-php-solutions/fpdi/

Andy
  • 2,764
  • 6
  • 24
  • 33