Print Long Text in multiple pages

Print Long Text in multiple pages

Postby nageswaragunupudi » Wed May 03, 2023 12:18 am

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn, oFont, oBold, oPen, cText, cRtf, nRow
   local nWidth, nBottom

   cRtf  := MEMOREAD( "testrtf.rtf" )
   cText := MEMOREAD( cFileSetExt( ExeName(), "prg" ) )

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME "Consolas" SIZE 0,-10 OF oPrn
   DEFINE FONT oBold NAME "VERDANA"  SIZE 0,-24 BOLD OF oPrn
   DEFINE PEN oPen WIDTH 1 OF oPrn

   oPrn:SetPage( 1 ) // Letter or 4 for A4

   nWidth   := oPrn:PageWidth(  "INCHES" ) - 2 // Margins 1"
   nBottom  := oPrn:PageHeight( "INCHES" ) - 1

   PAGE

   @ ( nRow := 1 ), 1 PRINT TO oPrn TEXT "PRINT TEXT ACROSS PAGES" ;
         SIZE 6,1 INCHES LASTROW nRow FONT oBold ALIGN "TC"
   oPrn:Line( nRow, 1, nRow, nwidth + 1, oPen, "INCHES" )

   nRow  := PrintMultiPage( oPrn, nRow + 0.5, cText, nWidth, 1, nBottom, oFont, oPen )

   oPrn:Line( ( nRow += 0.1 ), 1, nRow, 8, oPen, "INCHES" )

   nRow := PrintMultiPage( oPrn, nRow + 0.5, cRtf, nWidth, 1, nBottom, oFont, oPen )

   oPrn:Line( ( nRow += 0.1 ), 1, nRow, 8, oPen, "INCHES" )

   @ ( nRow += 0.1 ) ,1 PRINT TO oPrn TEXT "*** END OF REPORT ***" SIZE 7,1 INCHES

   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont, oBold
   RELEASE PEN oPen

return nil

static function PrintMultiPage( oPrn, nRow, cText, nWidth, nTopRow, nBottomRow, oFont, oPen )

   @ nRow, 1 PRINT TO oPrn TEXT @cText SIZE nWidth, ( nBottomRow - nRow ) INCHES ;
      FONT oFont LASTROW nRow

   do while !Empty( cText )
      ENDPAGE
      PAGE
      PageNo( oPrn, oFont, oPen )
      @ nTopRow, 1 PRINT TO oPrn TEXT @cText SIZE nWidth, nBottomRow - nTopRow ;
         INCHES FONT oFont LASTROW nRow
   enddo

return nRow

static function PageNo( oPrn, oFont, oPen )

   local nRow

   @ 0.5,1 PRINT TO oPrn TEXT TRANSFORM( oPrn:nPage, "Page : ##" ) ;
      SIZE 6,1 INCHES FONT oFont ALIGN "TR" LASTROW nRow
   oPrn:Line( nRow += 0.1, 1, nRow, 8, oPen, "INCHES" )

return nil
 


Image
Regards

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

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests