Page 1 of 1

problem in reading .rtf document

Posted: Tue Oct 04, 2005 2:24 am
by bskhas
Hi everyone,

I am trying to read a .rtf document. I m using the following line of code just for testing purpose.

$fileName = "/usr/local/apache/htdocs/abc/testing.rtf";
$data = fopen($fileName, "r");
$data1 = fread($data, filesize($fileName));
echo $data1;

The above line of code gives output in the following maner in the browser window.

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 This is a sample tesst page. Lets c it reads it or not.\par \par \b The bold text\par \par \b0 This is testing.\par }

so anyone here can help me to get the exact text of the .rtf document through php code ?

i'll be waiting for someones response...

Thnx .........

Posted: Tue Oct 04, 2005 7:08 am
by feyd
that is the exact text. :?

Posted: Tue Oct 04, 2005 7:39 am
by Grim...
I assume you only want plain text, for instance:
-------------------
This is a sample tesst page. Lets c it reads it or not.

The bold text

This is testing.
-------------------

?

I've got a feeling this might be very difficult.

However, you could take a look at http://www.phpwordlib.motion-bg.com/

Posted: Tue Oct 04, 2005 4:55 pm
by Ambush Commander
RTF is an open format, there's no reason why someone shouldn't have built a PHP RTF parser converter into HTML.

In fact, if no one has, that sounds like a good project...

Wikipedia has info and links to specifications: http://en.wikipedia.org/wiki/Rich_Text_Format