/*
Author: Reinaldo Crespo-Bazán
Date : 10/25/2010
Source: viewtopic.php?f=3&t=15270
Note: Convert RTF text to plain text
*/
#DEFINE _cREGEX "\{?\\([a-z]{1,32}[0-9]* ?)([A-z, ]*;)?|}" //includes fonts
function GetTextFromRTF( cRtfText, lKeepCRLFs )
local aRet
local cStrip, i
DEFAULT cRtfText := ""
DEFAULT lKeepCRLFs := .t.
aRet := hb_RegExAll( _cREGEX, cRtfText, .f. )
if aRet == Nil ;return cRtfText ;endif
aSort( aRet,,, { |x,y| len( x[1] ) > len( y[1] ) } )
for i := 1 to len( aRet )
cRtfText := StrTran( cRtfText, aRet[ i, 1 ], "" )
Next
if !lKeepCRLFs
cRtfText := StrTran( cRtfText, CRLF, " " )
endif
Return cRtfText
byte-one wrote:James, thanks!
A good code! Meanwhile i found all required functions.
oRichEdit:GetText()
Now i explored the GTF-Format
Yes GetText() method works best but requires to initialize the object which will require a dialog or window. When working on the background , when pulling text from a Blob field or when no RichText object is needed, then my function GetTextFromRTF() is the only choice.
I am also looking for it there is any way to "render" rtf and html in a rectangle (not a control). I greatly appreciate any suggestions.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 41 guests