Reading pdf and doc files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gops_kn
Forum Newbie
Posts: 3
Joined: Fri Sep 26, 2003 2:25 am

Reading pdf and doc files

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
vangelis
Forum Newbie
Posts: 23
Joined: Thu Jun 05, 2003 6:35 am

Post by vangelis »

How about if you are not using windows?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

hard luck i think :(
gops_kn
Forum Newbie
Posts: 3
Joined: Fri Sep 26, 2003 2:25 am

Reading .doc and .pdf file

Post 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
Post Reply