Forum Moderators: coopster
Jatses
Let me ask some questions.
Where are your RTF files stored?
.... If they are stored in the DB, how are they stored? Text field?
Do you want the files to be dynamically created from the DB or what?
Del
Do you want the files to be dynamically created from the DB or what?
~ I just want PHP to convert the text from RTF format to HTML.
Like I tried to state earlier (with a different scenario), I have a VB.NET application that I login to so I can add new products to the DB. Now, each product has a description and some of the words in the description I want to have emphasized (whether bold, italics, different color, size, font, or highlighted). In order to do that in VB.NET I had to use a RichTextBox control which formats the text in RTF. I am unable to convert the RTF text from that control into HTML in VB.NET so I am just saving it to the DB in a text field with the RTF formatting. So, what I want is to use PHP to convert the product description from RTF to HTML. Right now I don't care if I only do it once and then resave it to the DB or I do it dynamically each time the product description is displayed. Hope this makes better since. Thanks for viewing and helping!
Jatses
If you want to keep it all CSS, and avoid using html font tags, then you will need to create html span or div tags (with a style attribute) when you have font typeface, size, and/or color changes.
The conversion algorithm should be straight forward. You scan the RTF raw text looking for "{" characters. When you find one, look for the closing "}". Then determine which RTF tag(s) are involved and write the corresponding HTML tag(s).
When multiple changes are applied to the same block of text, RTF will put it all into one set of {}. Much like a the style attribute of an HTML entity.
You should be able to track down a list of possible RTF codes on the internet somewhere. Alternatively, you could create a few test documents with the interface you have created and then inspect it as a text file.
If I recall, the best source I could find for RTF codes was the help compiler documentation for VB 1.0. (yes, 1.0 - the help editor was an optional add-on that you had to pay $50 for. So I guess they felt they had to actually document it)
Sorry I can't be more specific. It has been at least 8 years since I have done any RTF conversions, and I did a memory dump a while ago to make room for other stuff. :)