Assigning lUseHaruPdf when TPrinter is sub-classed

Re: Assigning lUseHaruPdf when TPrinter is sub-classed

Postby nageswaragunupudi » Thu Aug 03, 2023 7:55 am

Unfortunately when it's printing in a loop (a bunch of staffs tax calculation), it will eventually generates internal error

After how many times in the loop?
Regards

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

Re: Assigning lUseHaruPdf when TPrinter is sub-classed

Postby hua » Thu Aug 03, 2023 8:10 am

About 18 and some of the generated pdfs are blank with a filesize of 1.4KB only
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Assigning lUseHaruPdf when TPrinter is sub-classed

Postby nageswaragunupudi » Sat Aug 05, 2023 9:47 am

I tested this program to generate 200 pdf files silently and all 200 files were created in 1.1 seconds and no crash, no errors and no log files about excess font release.
I have used native fwh library without modifications.
I tested it with FWH1912.

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

REQUEST FWHARU
REQUEST DBFCDX

function Main()

   local nMax  := 200
   local bData, cData, cPdf, n, nSecs
   local cLog  := cFileSetExt( ExeName(), "log" )

   FWNumFormat( "E", .t. )
   TPrinter():lUseHaruPDF := .t.

   FERASE( cLog )
   AEVAL( DIRECTORY( "CUST???.PDF" ), { |a| FERASE( a[ 1 ] ) } )

   USE CUSTOMER NEW VIA "DBFCDX"
   GO TOP

   bData := &( "{||{ID,TRIM(FIRST) + ', ' + LAST,STREET,CITY,STATE,AGE,SALARY}}" )

   nSecs := SECONDS()
   MsgRun( "CUST000.PDF", FWVERSION, { |oDlg| cPdf := MultiPDF( nMax, bData, oDlg ) } )
   nSecs := SECONDS() - nSecs

   ? "Created " + cValToChar( nMax ) + " pdfs in " + cValToChar( nSecs ) + " seconds"

   HtmlView( TrueName( cPdf ) )

   if File( cLog )
      WinExec( "notepad.exe " + cLog )
   else
      ? cLog + " not created"
   endif

return nil

static function MultiPDF( nMax, bData, oDlg )

   local cPdf,cData,n

   for n := 1 to nMax

      cData := FW_ArrayAsList( Eval( bData ), CRLF, .t. )
      cPdf  := "CUST" + STRZERO( n, 3, 0 ) + ".PDF"
      //
      oDlg:cMsg   := cPdf
      oDlg:Refresh()
      SysRefresh()
      //
      MakePDF( cData, cPdf )

      SKIP
      if EOF()
         GO TOP
      endif
   next

return cPdf

static function MakePDF( cData, cPdf )

   local oPrn, oFont
   local nRow, nCol

   PRINT oPrn FILE cPdf

   DEFINE FONT oFont NAME "COURIER NEW" SIZE 0,-12 OF oPrn

   PAGE
      for nRow := 1 to 7 step 2; for nCol := 1 to 4 step 3

      @ nRow, nCol PRINT TO oPrn TEXT cData SIZE 3,2 INCHES ;
            FONT oFont

      next; next
   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont

   oPrn  := nil

return nil

You can try coping this program to fwh\samples folder and try building with buildh.bat or buildx.bat.
Regards

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

Re: Assigning lUseHaruPdf when TPrinter is sub-classed

Postby hua » Mon Aug 07, 2023 2:21 am

Thanks Rao.
I was using :lUseFWPdf instead of :lUseHaruPdf in my test that ends up with internal error.
I'll try to slowly shift to :lUseHaruPdf and see how it goes
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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