Page 1 of 1
How to retrive plain Text form an RTF DB Field?
Posted: Thu Nov 26, 2009 8:58 am
by Juergen
I have RTF formated text in some Database fields. Sometime I need the unformatted Text for export to a plain Text file. In this routine I have no DBRichView(Edit) field on hand.
What is the easiest way to extract the plain Text from the RTF formated field?
Posted: Thu Nov 26, 2009 10:14 am
by Sergey Tkachenko
See
http://www.trichview.com/forums/viewtopic.php?t=2702
It uses ReadFromFile method, but you can use ReadFromStream to read RTF from DB.
Posted: Fri Nov 27, 2009 8:29 am
by Juergen
Hi Sergey,
this solution solved my problem. Thanks for your help.
Jürgen
Posted: Mon Jul 11, 2011 11:09 am
by Alexander_Dober
Hello,
I'm trying to get this working for an unicode text and use OnNewUnicodeText of the parser as suggested in the linked article, but the event seems not to get fired since DoReaderText isn't being executed.
If I use the OnNewText event, it is being fired, but the result is wrong for a unicode text.
Does it have to be a RTF-Code stored with the DBRichView? At the moment it's being saved with a RzDBRichViewEdit / a cxDBRichEdit and looks like this:
Code: Select all
{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset204 Calibri;}{\f1\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\f0\fs24\'ef\'f0\'ee\'e3\'f0\'e0\'ec\'ec\'e8\'f0\'ee\'e2\'e0\'ed\'e8\'e5\f1\par
}
It's strange to see "...\ansi\..." in the code, but it's always the same and the RichEdits seem to be fine with that...
Any idea why OnNewUnicodeText doesn't get fired?
Posted: Mon Jul 11, 2011 3:28 pm
by Sergey Tkachenko
I added a new demo for extracting Unicode text, in the same topic.
For Unicode text, both OnNewText and OnNewUnicodeText events must be used. OnNewUnicodeText is called only when RTF contains Unicode characters. For ANSI characters, you need to use OnNewText and convert the read text to Unicode.
Posted: Mon Jul 11, 2011 3:31 pm
by Alexander_Dober
I don't see any differences between the new and the old demo. Looks as if it's the old one
Posted: Mon Jul 11, 2011 4:49 pm
by Sergey Tkachenko
Posted: Mon Jul 11, 2011 5:08 pm
by Alexander_Dober
Works fine, thanks a lot!