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.
Reading pdf and doc files
Moderator: General Moderators
to get the number of words in a doc file
Unfortunately, the COM functions only work an the windows platform!
Mark
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();Mark
Reading .doc and .pdf file
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
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