problem in reading .rtf document

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
bskhas
Forum Newbie
Posts: 5
Joined: Thu Aug 18, 2005 1:05 am
Contact:

problem in reading .rtf document

Post 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 .........
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that is the exact text. :?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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/
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

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