How to retrive plain Text form an RTF DB Field?

General TRichView support forum. Please post your questions here
Post Reply
Juergen
Posts: 9
Joined: Thu Nov 05, 2009 8:47 pm
Location: Germany

How to retrive plain Text form an RTF DB Field?

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Juergen
Posts: 9
Joined: Thu Nov 05, 2009 8:47 pm
Location: Germany

Post by Juergen »

Hi Sergey,

this solution solved my problem. Thanks for your help.

Jürgen
Alexander_Dober
Posts: 130
Joined: Fri Mar 04, 2011 3:44 am

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Alexander_Dober
Posts: 130
Joined: Fri Mar 04, 2011 3:44 am

Post by Alexander_Dober »

I don't see any differences between the new and the old demo. Looks as if it's the old one ;)
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Alexander_Dober
Posts: 130
Joined: Fri Mar 04, 2011 3:44 am

Post by Alexander_Dober »

Works fine, thanks a lot!
Post Reply