FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Assigning lUseHaruPdf when TPrinter is sub-classed
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Assigning lUseHaruPdf when TPrinter is sub-classed
Posted: Thu Aug 03, 2023 07: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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Assigning lUseHaruPdf when TPrinter is sub-classed
Posted: Thu Aug 03, 2023 08: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Assigning lUseHaruPdf when TPrinter is sub-classed
Posted: Sat Aug 05, 2023 09: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 (fw): Select all Collapse
#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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Assigning lUseHaruPdf when TPrinter is sub-classed
Posted: Mon Aug 07, 2023 02: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

Continue the discussion