I use Delphi XE5 (only Windows platform). I need to show RTF documents and be able to extract plain text (for search operations). I created small test app, it has few components:
RichEdit1: TRichEdit;
cxRichEdit1: TcxRichEdit;
WPRichText1: TWPRichText;
Button2: TButton;
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
and such code (load same RTF file to TRichEdit / TcxRichEdit / TWPRichText and extract plain text to corresponding memos):
RichEdit1.Lines.LoadFromFile('c:\d\1.rtf');
cxRichEdit1.Lines.LoadFromFile('c:\d\1.rtf');
WPRichText1.LoadFromFile('c:\d\1.rtf', True, 'RTF');
memo1.Text := RichEdit1.Text;
memo2.Text := cxRichEdit1.Text;
memo3.Text := WPRichText1.SaveToString('UNICODE');
And i have such results.
TRichEdit:
???????? <http://news.tut.by/politics/> ...
Failed to extract unicode chars (system locale is Norwegian), contains URLs.
TcxRichEdit:
HYPERLINK "http://news.tut.by/politics/"ПОЛИТИКА ...
Unicode chars are ok, but shows URLs as part of the plain text.
TWPRichText:
ПОЛИТИКА
The only component who does the job correctly. But i would like to avoid of use TWPRichText, because it is heavy and slow. Does anyone know, is it possible to solve the problem with standard TRichEdit? Sample of RTF can be downloaded here.