Page 1 of 1
New: Print/Display RichText
Posted: Fri Mar 25, 2022 3:27 am
by nageswaragunupudi
From the next version onwards, the same methods/commands which we have been using all along for display/print multi-line text, will display/print RichText also, without any additional coding by the programmer.
Code: Select all | Expand
oWnd:SayText( cText, aRect, ... )
oPrn:SayText( cText, aRect, ... )
@ r,c PRINT TO oPrn TEXT cText SIZE w,h INCHES/CM/MM
samples\rtfprn.prg
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local oPrn, cText, cRtf, oFont, oBold
cText := MEMOREAD( "rtfprn.prg" )
cRtf := MEMOREAD( "testrtf.rtf" )
PRINT oPrn PREVIEW
DEFINE FONT oFont NAME "LUCIDA CONSOLE" SIZE 0,-10 OF oPrn
DEFINE FONT oBold NAME "ARIAL" SIZE 0,-20 OF oPrn
PAGE
oPrn:Say( 0.5, 0.8, "Rich Text", oBold,,,,, "INCHES" )
oPrn:Box( 0.8, 0.8, 5.2, 7.2,,,, "INCHES" )
@ 1, 1 PRINT TO oPrn TEXT cRtf SIZE 6,4 INCHES
oPrn:Say( 5.5, 0.8, "Normal Text", oBold,,,,, "INCHES" )
oPrn:Box( 5.8, 0.8, 10.2, 7.2,,,, "INCHES" )
@ 6, 1 PRINT TO oPrn TEXT cText SIZE 6,4 INCHES FONT oFont
ENDPAGE
ENDPRINT
RELEASE FONT oFont, oBold
return nil
Same syntax is used for both normal text and rich text.

Re: New: Print/Display RichText
Posted: Fri Mar 25, 2022 3:33 am
by nageswaragunupudi
Display RichText in any rectangular area of a window/dialog/control, by using the same method oWnd:SayText( cRichText, aRect )
Code: Select all | Expand
oWnd:bPainted := <|hDC|
local oRect := oWnd:GetCliAreaRect()
oRect += { 60, 60, -60, -60 }
oWnd:SayText( cRtf, oRect:aRect )
oRect += { -20, -20, 20, 20 }
oWnd:Box( oRect:nTop, oRect:nLeft, oRect:nBottom, oRect:nRight )
return nil
>

Re: New: Print/Display RichText
Posted: Fri Mar 25, 2022 9:36 pm
by cmsoft
Excelente!!! Muy buen aporte!
Felicitaciones!
Re: New: Print/Display RichText
Posted: Mon Mar 28, 2022 7:02 pm
by TimStone
I will greatly appreciate this capability.
Will this also work automatically in PREVIEW mode ?
Do we have an ETA for the next version ?
Thanks so much for all the effort on this capability.
Re: New: Print/Display RichText
Posted: Tue Mar 29, 2022 4:02 am
by nageswaragunupudi
Will this also work automatically in PREVIEW mode ?
Yes
Do we have an ETA for the next version ?
Early April 22.
Re: New: Print/Display RichText
Posted: Tue Mar 29, 2022 8:42 am
by Silvio.Falconi
Could you also bring in the justification of the paragraphs?
Re: New: Print/Display RichText
Posted: Mon Jun 20, 2022 5:38 am
by nageswaragunupudi
Silvio.Falconi wrote:Could you also bring in the justification of the paragraphs?
Richtext allows formatting paragraphs with justification.
Re: New: Print/Display RichText
Posted: Mon Jun 20, 2022 5:38 am
by nageswaragunupudi
From the next version it is possible to split across pages.
Re: New: Print/Display RichText
Posted: Mon Jun 20, 2022 6:12 am
by Detlef
That's great news.
Many thanks for this excellent development.
Re: New: Print/Display RichText
Posted: Fri Jul 01, 2022 5:51 pm
by nageswaragunupudi
We were able to split normal text across pages. From ver 22.06, it is possible to split rich text also with the same syntax.
Sample:
Code: Select all | Expand
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local oPrn, oLarg, oFont, oPen, nLastRow
local cNotes := HB_MEMOREAD( "c:\fwh\samples\test.rtf" )
PRINT oPrn PREVIEW
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn
DEFINE FONT oLarg NAME "TAHOMA" SIZE 0,-40 BOLD OF oPrn
DEFINE PEN oPen WIDTH 1 OF oPrn
PAGE
oPrn:Box( 0.9, 0.9, 7.6, 7.1, oPen, nil, ;
{ "MAIN" + CRLF + "REPORT", oLarg }, ;
"INCHES" )
oPrn:Say( 7.9, 1.00, "Notes: ( Normal Text or Rich Text )", ;
oFont, 6.0, nil, nil, nil, "INCHES" )
@ 8.5, 1.0 PRINT TO oPrn TEXT @cNotes SIZE 6.0, 1.5 INCHES ;
LASTROW nLastRow
oPrn:Box( 8.40, 0.90, nLastRow + 0.1, 7.10, oPen, nil, nil, "INCHES" )
ENDPAGE
do while .not. Empty( cNotes )
PAGE
@ 1.0, 1.0 PRINT TO oPrn TEXT @cNotes SIZE 6.0, 9.0 INCHES ;
LASTROW nLastRow
oPrn:Box( 0.90, 0.90, nLastRow + 0.1, 7.10, oPen, nil, nil, "INCHES" )
ENDPAGE
enddo
ENDPRINT
RELEASE FONT oFont, oLarg
RELEASE PEN oPen
return nil
//----------------------------------------------------------------------------//

Re: New: Print/Display RichText
Posted: Fri Jul 01, 2022 10:38 pm
by cmsoft
Excelente aporte Mr. Rao. Creo que con esto se pueden generar y combinar para hacer reportes personalizados de alta calidad!
Aprovecho para consultarle sobre algo que se consultó en este hilo:
viewtopic.php?f=6&t=41905&start=15 Hay alguna posibilidad que al leer un archivo .rtf también se pueda traer el encabezado y pie de página?
Desde ya muchas gracias
Re: New: Print/Display RichText
Posted: Sat Jul 02, 2022 5:17 am
by nageswaragunupudi
Hay alguna posibilidad que al leer un archivo .rtf también se pueda traer el encabezado y pie de página?
Need some time please.