I have a table and in it there are records which are saved in RTF format. Now on my website i have a php script that does a select on the table and returns the records, each record is entered into a row. I need to convert each record which is in RTF to normal text.
This what a record will look likein RTF format:
{¬rtf1¬ansi¬ansicpg1252¬deff0¬deflang1033{¬fonttbl{¬f0¬fnil¬fcharset0 MS Sans Serif;}}
¬viewkind4¬uc1¬pard¬f0¬fs17 hello
¬par }
All i want is to display (in this case):
hello (with relevant italics, bold and underline.)
So basically what i need is to convert RTf to plain text,
I have searched on the net and have had NO success so I would really appreciate some help.
thanx in advance
Angelo
>So basically what i need is to convert RTf to plain text,
>
>I have searched on the net and have had NO success so I would really appreciate some help.
The RTF spec is availavble at
http://msdn.microsoft.com/library/?url=/library/en-us/dnrtfspec/html/rtfspec.asp
Jason Stechschulte's rtf2html script
(http://px.sklar.com/code.html?code_id=413), which would be a good
starting point, seems to have gone walkabout but it's still available in
the Wayback Machine
(http://web.archive.org/web/20020627014409/http://px.sklar.com/code-pretty.html?code_id=413)
you will need to parse the RTF file. You search for the RTF file speification. I have searched for that a while ago, and I know that RTF files have different versions. This may be relevant to you.
If you want to just extract the plain text, it is relatively easy, you will just have to strip the formating code (kinda similar to HTML), but if you want to keep BOLD, ITALIC and UNDERLINE you will have to work more.
I am not sure, but I think you might do this with (tons) REGEX. =)
Hope you got a start here,
Regards,
*** Quote from original message ***
Date: Fri, 16 May 2003 11:50:36 +0200
From: "Angelo Zanetti" <bi...@ctech.ac.za>
Subject: RTF to plain text
To: <php-g...@lists.php.net>
Hi ppl.
I have a table and in it there are records which are saved in RTF
format. Now on my website i have a php script that does a select on
the table and returns the records, each record is entered into a row.
I need to convert each record which is in RTF to normal text.
This what a record will look likein RTF format:
{毒tf1柑nsi柑nsicpg1252查eff0查eflang1033{柏onttbl{柏0柏nil柏charset0
MS Sans Serif;}}
洋iewkind4泉c1殆ard柏0柏s17 hello
殆ar }
All i want is to display (in this case):
hello (with relevant italics, bold and underline.)
So basically what i need is to convert RTf to plain text,
I have searched on the net and have had NO success so I would really
appreciate some help.
thanx in advance
Angelo
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup