Page 1 of 1

Reading pdf and doc files

Posted: Fri Sep 26, 2003 2:25 am
by gops_kn
I am right now working with a project that need file handling and reading the contents inside the same.
What I need is, get the number of words from the file. For text and rtf I feel no problem. But the problem exists for .doc and .pdf's.
Does anyone know any piece of code or any library function in PHP that is able to read the contents inside the .doc and pdf . Or any function that counts the words inside the doc and pdf.
If answered, it will be very helpful for me

Thanks in advance.

Posted: Fri Sep 26, 2003 3:23 am
by JayBird
to get the number of words in a doc file

Code: Select all

$word = new COM("word.application") or die("Unable to instantiate Word"); 

$word->Visible = 1; 

$word->Documents->Open("c:/anydocument.doc");
$temp = $word->Dialogs->Item(228);
$temp->Execute();
$numwords = $temp->Words();

echo $numwords;

$word->Quit();
Unfortunately, the COM functions only work an the windows platform!

Mark

Posted: Fri Sep 26, 2003 7:52 am
by vangelis
How about if you are not using windows?

Posted: Fri Sep 26, 2003 8:10 am
by JayBird
hard luck i think :(

Reading .doc and .pdf file

Posted: Fri Sep 26, 2003 11:08 pm
by gops_kn
Thanx for the fast response

The code works pretty well with windows platform. At present we are working in windows, and it seems the hosting party is using linux platform.
Does any function/tools are there for these......

As pointed I need a pdf file also to be opened by the php. The system should read the contents with in the file. Is that possible.

How about the function 'pdf_open_pdi'. I have not yet tried, as pdflib.I have not tried as pdflib is not configured yet. Any idea regarding this


Gops