Printing RTF 22.03

Printing RTF 22.03

Postby TimStone » Mon Apr 11, 2022 9:40 pm

I started working with the new command that allows us to print Rich Text Format using the newest FWH release. I would like to provide the following:

First, consider this existing code that prints a multi-line text from a memo field.
Code: Select all  Expand view  RUN

   FOR lx := 1 TO MLCount( oEndText:tagtext, 120,, .T. )
      WOPAGEHEAD( oPrn, aHead )
      IF lPrintColor
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond, , CLR_RED )
      ELSE
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond )
      ENDIF
      nRow += nRsp
   NEXT
 


The function WOPAGEHEAD( ) checks the row number to be sure there is enough space for the next line on the page , If not, it advances to the next sheet, prints the header, and then continues to print the text from the memo field. Also, because the nRow is updated with each line, we know where to start printing the next section after the information contained in the memofield.

Using the new implementation, I find the following issues:
1) You have used a defined dimensions sample. This is not the same as the presenting problem in the original thread which wants to print the text inline with other information that was already printed, and before additional information. The example cited was disclaimer text that comes near the end of a printed invoice.
2) Using the following code for 22.03
Code: Select all  Expand view  RUN
  cRTF := oEndText:tagtext
  oPrn:SayText( nRow, 2*nCSP, cRTF, nCsp*80, nRsp * 6.1 )

I can print the text. The text is actually saved as RTF in the memo field. However, the size of this text can vary a lot. So, I need to be able to determine the amount of space I will be needing, based on the content of the RTF, and be able to track the printed rows. I need to know when to cutoff printing on one sheet and start on the next. Perhaps there are already functions that can determine this. Using them, as in the first coding sample, I could then feed the data appropriately to the print routine.

I hope this isn't too confusing. What we have is significant, but I think we will see this be a concern no matter what type of RTF content we ultimately decide to print. We must handle the length and page breaks.

I am very willing to test any ideas. I'm already experimenting with this.

Thank you for all the work on this implementation. I do appreciate it.
Last edited by TimStone on Tue Apr 12, 2022 12:39 am, edited 1 time in total.
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: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Pring RTF 22.03

Postby cmsoft » Mon Apr 11, 2022 11:44 pm

Tim
This code works with plain text, but not with rtf.
Maybe Mr. Rao can tell us some solution.
Code: Select all  Expand view  RUN

#include "fivewin.ch"

function Main()

   local oPrn, cRtf,  oBold, nPage := 1

   cRtf  := MEMOREAD( "fivedit.prg" )  

   DEFINE FONT oBold NAME "ARIAL" SIZE 18,36 OF oPrn

   PRINT oPrn PREVIEW  
      PAGE
         REPEAT  
            @ 0, 1 PRINT TO oPrn TEXT "Page:" + str(nPage,3) FONT oBold SIZE 19,.9 ALIGN "C" CM

            @ 1, 1 PRINT TO oPrn TEXT @cRtf FONT oBold  SIZE 19,22 CM

            IF !empty(cRtf)
               nPage ++
               ENDPAGE
               PAGE            
            ENDIF
         UNTIL empty(cRtf)
      ENDPAGE
   ENDPRINT
   RELEASE FONT oBold
return nil
 

This code not work
Code: Select all  Expand view  RUN

function Main()

   local oPrn, cRtf,  oBold, nPage := 1

   cRtf  := MEMOREAD( "fiveodbc.rtf" )  

   DEFINE FONT oBold NAME "ARIAL" SIZE 18,36 OF oPrn

   PRINT oPrn PREVIEW  
      PAGE
         REPEAT  
            @ 0, 1 PRINT TO oPrn TEXT "Page:" + str(nPage,3) FONT oBold SIZE 19,.9 ALIGN "C" CM

            @ 1, 1 PRINT TO oPrn TEXT @cRtf  SIZE 19,22 CM

            IF !empty(cRtf)
               nPage ++
               ENDPAGE
               PAGE            
            ENDIF
         UNTIL empty(cRtf) .or. nPage > 10  // Pongo esto porque sino nunca termina
      ENDPAGE
   ENDPRINT
   RELEASE FONT oBold
 

Always show the first page of the rtf
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Printing RTF 22.03

Postby nageswaragunupudi » Tue Apr 12, 2022 9:25 am

Both of you are correct.
We are in the process of making further improvements. In particular, the points raised by you, viz.,

1. Estimating the height required in advance
2. Returning the remaining text

are two issues at the top of our mind.
We will keep you all informed about the progress.
Regards

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

Re: Printing RTF 22.03

Postby cmsoft » Tue Apr 12, 2022 11:50 am

Muchas gracias Mr. Rao, sería de muchisima utilidad.
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Printing RTF 22.03

Postby nageswaragunupudi » Tue Apr 12, 2022 12:21 pm

Instead of this:
Code: Select all  Expand view  RUN
 FOR lx := 1 TO MLCount( oEndText:tagtext, 120,, .T. )
      WOPAGEHEAD( oPrn, aHead )
      IF lPrintColor
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond, , CLR_RED )
      ELSE
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond )
      ENDIF
      nRow += nRsp
   NEXT
 


This is better and recommended
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oPrn, cRtf,  oBold, nPage := 1

   cRtf  := MEMOREAD( "fivedit.prg" )  

   DEFINE FONT oBold NAME "ARIAL" SIZE 18,36 OF oPrn

   PRINT oPrn PREVIEW  
      PAGE
         REPEAT  
            @ 0, 1 PRINT TO oPrn TEXT "Page:" + str(nPage,3) FONT oBold SIZE 19,.9 ALIGN "C" CM

            @ 1, 1 PRINT TO oPrn TEXT @cRtf FONT oBold  SIZE 19,22 CM

            IF !empty(cRtf)
               nPage ++
               ENDPAGE
               PAGE            
            ENDIF
         UNTIL empty(cRtf)
      ENDPAGE
   ENDPRINT
   RELEASE FONT oBold
return nil
 
Regards

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

Re: Printing RTF 22.03

Postby TimStone » Tue Apr 12, 2022 2:48 pm

Nages,

You are using command structure, and of course it is converted to the class structure. Using the print object ( oPrn ), I am simply using the class directly.

Also, I don't need MEMOREAD because the RTF is stored in that format using SaveAsRTF( ). Thus:

Code: Select all  Expand view  RUN
cRTF := oEndText:tagtext
  oPrn:SayText( nRow, 2*nCSP, cRTF, nCsp*80, nRsp * 6.1 )  

does work properly.

Here is the issue. The Invoice, because it is complex in it's output and options, is 1527 lines of code. The output can be an unlimited number of pages, thus the necessary page counter logic. The implementation of printing of the RTF is assuming a block size which must be modified to be used in this case. One customer might have 5 lines of text in RTF format, another might have 20. If they vary the font and size of the characters, with bold, underlining, etc, the commands will not give an accurate count of the lines needed. We have to draw that from the formatted output. Also, because of the way this is handled, in a block size, we can't split it. A person might have 20 lines of "disclaimer" ( often called fine print on the end of a invoice ), and only 6 will print on the first page. If you look at my example, you will see we check the row after each line is printed. If the number exceeds what can be printed on a page ( usually 54 lines considering a top and bottom margin ), then it ejects the page, prints the header info on a new page, and then resumes printing the text.

I will email you a sample printout ( PDF ) so you can get an idea of what I am referring to. I will be happy to modify the printer.prg and test any ideas you have.
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: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Printing RTF 22.03

Postby nageswaragunupudi » Tue Apr 12, 2022 3:02 pm

The point we were making is while printing normal multi-line text across pages, we do not need the outdated method of using memoline()s.
oPrn:SayText() will automatically help, if you closely observe the code.

But right now, this is not possible with RTF text. We understand your issue.
As I said we are working on this issue. This is highly complex but we are working on it.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests