RTF from Variable

Re: RTF from Variable

Postby cnavarro » Fri Dec 03, 2021 11:49 pm

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: RTF from Variable

Postby TimStone » Mon Dec 06, 2021 11:57 pm

No my questions were not answered in that post. I had already reviewed it many times but look again. Let me be specific:

DOES ANYONE USE RTF with a FW Memo field ? Does anyone print RTF along with regular code in a custom PRINTER class printout ? I have heard it is possible, but have seen no completed code or documentation to demonstrate this.


ISSUE 1:

Using the updated RichEdit5.prg, with a resource file, I can read text from a memo field ( DBFCDX ) into a variable, and then modify it with RichEdit including highlighting, spell checking, etc. Now, I want to save that modified text ( with RichEdit formatting ) back to the MEMO field in the .dbf. For years I heard this was possible, but see no examples or documentation. I've looked at the code, tried many different things, and have not found the solution.

ISSUE 2:

I have an invoice that uses the PRINTER class ( NOT THE REPORT OPTION ). There are a lot of formatting options in the structure, with calculations. and decision trees, throughout. This cannot be done with the report class. I previously shared how I print MEMO fields. My question was specific: Is there a PRINTER command to output the RTF data which I can replace the example I used? Remember, this is just one small part of the full invoice which is written 100% with PRINTER syntax.

Once I can see how these methods are applied, then I can implement them specifically in my application.

Thank you.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby Antonio Linares » Thu Dec 09, 2021 8:57 am

Tim,

Alias->YourMemoField := oRichEdit:SaveAsRTF()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RTF from Variable

Postby Antonio Linares » Thu Dec 09, 2021 9:00 am

Tim,

c:\fwh\samples\report\rep22.prg is an example of using RTF from a report

both questions answered :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RTF from Variable

Postby TimStone » Thu Dec 09, 2021 9:10 pm

Antonio,

1) Using the save puts the text into the memofield with the formatting commands. However, when I retrieve that text the next time, it is NOT in RTF format. It shows all the formatting commands. I have reviewed this thread about a dozen times and tried every option provided for retrieving the text and making it ready for the RTF edit, but none of them work. All of the efforts were made several years ago, so I assume updates to the code may have changed.

Here is the code I have:

Code: Select all  Expand view  RUN

FUNCTION setup3
    // Text Editor for disclosures
    //  Updated:    7/30/2015 5:55:48 PM
   
    LOCAL oEndText, oDlg, nRcrd, oRich
    PRIVATE cText := " ", cTitle := " ", cRtf := " "
   
    // Open the text database
    oEndText := tEndText():New( )
    oEndText:gotop( )
   
   
   
    // Load the text

  cText := oEndText:tagtext

    // Create the dialog
    DEFINE DIALOG oDlg RESOURCE "SETUP3" BRUSH oBrush transparent OF oWnd
    oDlg:nHelpID := 6

    REDEFINE BUTTONBAR oBarS3 ID 100 SIZE 60,60 OF oDlg 2015
            oBarS3:bClrGrad := aPubGrad

           
    DEFINE BUTTON oWBtn3 OF oBarS3 RESOURCE "HRSAVE" ;
        ACTION (  oEndText:tagtext :=  oRich:SaveasRTF( cText ),  oEndText:save() )
    DEFINE BUTTON oWBtn5 OF oBarS3 RESOURCE "HREXIT" ;
        ACTION oDlg:end()

    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cText ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  BARBUTTON  

    ACTIVATE DIALOG oDlg  CENTERED

    // Close the file
    oEndText:close()
   
RETURN NIL


 


Suggestions ? I've tried the various Set and Load options described in this thread. There does not seem to be a final one.

2) rep22.prg does not demo anything with .RTF. Also, my question is doing a printout of RTF text with the PRINTER class, and NOT with a report. As stated above, for the complexity of my need, I cannot use a REPORT. I need the equivalent for RTF of this output:

oPrn:SayText( nRow, 10 * nCsp, MemoLine( oEndText:tagtext, 60, lx,, .T. ),,, oFnorm )

I would expect a SayRTF() Method but in the tPrinter class there is absolutely nothing that addresses RTF in any way. Perhaps there is another way ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby Antonio Linares » Thu Dec 09, 2021 9:14 pm

Tim,

ACTIVATE DIALOG oDlg ON INIT ( oRich:LoadRTF( cRTF ), .T. )

same logic
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RTF from Variable

Postby Antonio Linares » Thu Dec 09, 2021 9:19 pm

Tim,

RTF means "Rich Text format" which means different font sizes and colors and thats exactly what you can see in rep22.prg

If you need to use different font sizes and colors just using a Printer object, there are lots of examples we can provide you.

Simplicity is the key
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RTF from Variable

Postby TimStone » Fri Dec 10, 2021 2:08 am

Antonio,

Thanks for the first response. I can now save and retrieve from the memo field. That is perfect.

The data in that field is many lines long. It is disclaimer text printed at the end of every invoice. Here is the code to print the contents:

Code: Select all  Expand view  RUN

  IF cPRNTYP = "I"
      oEndText:goto( 3 )
      nRow += nRsp
      FOR lx := 1 TO MLCount( oEndText:tagtext, 60,, .T. )
         WOPAGEHEAD( oPrn, aHead )
         oPrn:SayText( nRow, 10 * nCsp, MemoLine( oEndText:tagtext, 60, lx,, .T. ),,, oFnorm )
         nRow += nRsp
      NEXT
   ENDIF


 


You said you have many examples of using the printer class to handle this. I would love to see the examples. Right now it prints the text with all the formatting symbols ( and displays it that way in Preview ). So my question is: What is the format to use with tPrinter class code to accomplish what I am showing you.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby Antonio Linares » Fri Dec 10, 2021 6:50 am

Dear Tim,

This is the syntax for Class TPrinter Method SayText()

METHOD SayText( nRow, nCol, cText, nWidth, nHeight, oFont, cAlign, nClrText, nClrBack, cUnits, ;
nOutLineClr, nPenSize )

Please notice that you can use ANY font in oFont parameter, different colors, pensize...

That is RTF power :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RTF from Variable

Postby TimStone » Fri Dec 10, 2021 6:19 pm

TO ALL =

I have started this in a NEW thread called "Print RTF using tPRINTER class ?????"

Maybe someone will read the post and understand what I need to do. Maybe I'm just getting too old to do this, but the comments keep missing the point of my need. I wish I could express it better.

Maybe a fresh start on the RTF printing question will be helpful.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby Antonio Linares » Sat Dec 11, 2021 7:41 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Antonio Linares, Silvio.Falconi and 84 guests