I need to convert rtf to plain text. i used to write a function that strips away rtf headers but it is never perfect.
So one option can be using a TRichEdit created at runtime (something like described here but done of course at runtime). But is there another way? Is there an rtl function for this or a better approach?
UPDATE:
In this question I wrote the final version of my rtf to text procedure.
Convert the RTF file to a text file using a word processor. To do this, first open the file in a program such as Microsoft Word or OpenOffice Writer. Select the “Save as” command in the File menu, choose the TXT format in the drop-down menu and click “Save.”
Find a desired location to save the file. From within the Save As Window, find the Save File Type field. Select the drop-down arrow, and change the file from Rich Text Format (rtf) to Word Document (doc). Select Save.
If you really want to find a way of doing this conversion you should take a look at how the class TConversion is implemented in the class TRichEditStrings. These classes are in ComCtrls.pas. By understanding how the conversion is done inside the RichEdit controls you may be able to write your own.
However, looking at the practical aspects of implementing this and not knowing what the performance requirements are for your question I would go for the TRichEdit conversion approach outlined in your link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With