Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count the number of words in a PDF document.

Status
Not open for further replies.

basil123

Programmer
Joined
Oct 16, 2003
Messages
1
Location
IN
Hello,

I have to develop an intranet application that reads documents and count the number of words in that document.I have done the same for text/html/word documents by reading the document using the fopen() function. I have to develop the site in PHP.

BUT i don't know how to do the same for PDF documents. From the php manual I got the information that by installing pdf libraries in the server, we could use functions related to pdf documents.I have downloaded the pdf libraries and installed in my web server.Following are the method that I have tried:

Since the function "pdf_open_pdi" is used to open an existing PDF document,I tried in that way with the following code:

$pdf = pdf_new();
pdf_open_file($pdf);
$pdi = pdf_open_pdi($pdf, "firstfile.pdf", "", 0);
$page= pdf_open_pdi_page($pdf, $pdi, 1, "");

But the script returns an error because of the function "pdf_open_pdi" returned a 0 handle. The file "firstfile.pdf" was there in the right path. I want to know why the function returns a handle 0. Because of this I could not use this document handle in the function "pdf_open_pdi_page".

If iam not in the right path please advice me how to count the number of words in a pdf document that exists in the web server.

Your thoughts and advice on this would be greatly appreciated.

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top