Is there a function Text-Format 2 RTF-Format and visversa and other functions to manage the RTF-Format?
Thanks!
Is there a function Text-Format 2 RTF-Format and visversa and other functions to manage the RTF-Format?
Thanks!
/*
Author: Reinaldo Crespo-Bazán
Date : 10/25/2010
Source: <!-- l --><a class="postlink-local" href="http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15270">viewtopic.php?f=3&t=15270</a><!-- l -->
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 cRtfTextJames, thanks!
A good code! Meanwhile i found all required functions.
Günther,
If you want to convert a RTF into standard text, then using a RichEdit control, you could do this:
oRichEdit:LoadRTF( cRTFText ) // RTF
MsgInfo( oRichEdit:GetText() ) // standard text
byte-one wrote:James, thanks!
A good code! Meanwhile i found all required functions.
Thanks to all!
In the meantime after tests i found, that many problems are waiting for me, using RTF for my project. Now i explored the GTF-Format. This is for me the right way as the complete source is reachable and no DLL is required.
By GTF do you mean "gene transfer format?"
oRichEdit:GetText()
Now i explored the GTF-Format
Reinaldo, GTF is part from FW! See FORMAT GET.
It can handle texts with different textcolors, fonts and aligns word for word or paragraph. RTF is much more complex!
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.
Once we create a richedit control (we can even use a hidden window) it is very easy to convert text to rtf or rtf to text. It is much better to have a function like Reinaldo's which works in all cases.
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.
Hello,
I am searching too a function like this one, but with accent support, lists, bullets, boxes, pictures, etc to be removed.
Is there an update?.
Thank you very much.
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.
Up please!.