extract text from richtext formated memo field

extract text from richtext formated memo field

Postby reinaldocrespo » Tue Apr 14, 2009 9:39 pm

Hi everyone!

I have richtext saved on memo fields. Sometimes I'd like to print just the text saved on the memo field. No richtext fonts and/or attributes. Just plain text. But don't want to go through the trouble and cpu time of defining the rtf control on screen before printing. Is it possible?

Example: Suppose I have this saved on the memo field:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 ARIAL;}}
\viewkind4\uc1\pard\f0\fs19      The specimen is labeled "GALLBLADDER", is submitted in formalin and consists of a gallbladder measuring 9 cm in length x 2.5 cm in maximum diameter. The serosa is purple-tan and smooth. The gallbladder wall averages 0.2 cm in thickness. The mucosa is green and flattened. Within the lumen admixed with green viscid bile are multiple yellow granular calculi measuirng 3 x 2 x 0.3 cm in aggregate. (RSS 1 CASS)  WVS:vsb  \par
}


Would print this:
The specimen is lablel "GALLBLADDER", is submitted in formalin and consists of a gallbladder measuring 9 cm in lenght....


No fonts no attributes. Just the text.

Can some help?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: extract text from richtext formated memo field

Postby nageswaragunupudi » Sat May 16, 2009 10:01 am

Could you find a solution ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: extract text from richtext formated memo field

Postby reinaldocrespo » Sat May 16, 2009 11:30 am

No. The only way I found to extract text from a richttext control is with: oRtf:GetText(). But that requires for the richtext control to be created which means that a window has to be defined also.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: extract text from richtext formated memo field

Postby reinaldocrespo » Sun Oct 24, 2010 7:05 pm

nageswaragunupudi;

I did find a solution to the problem:
Code: Select all  Expand view  RUN
#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
 


Regards,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests