FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Calculate total pages
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM

Calculate total pages

Posted: Wed Nov 22, 2023 05:31 PM

How can I calculate number of pages in a print using for instance

PRINT oPrn NAME "My Print" PREVIEW

PAGE

    WHILE !EOF()

      some instruction like

      Prn:Say( nRow, nCol  , bla bla )



      ENDPAGE

      PAGE

    ENDDO

ENDPAGE

ENDPRINT

does exist a clause that permits me to run the function without print anything only for calculate number of pages

it would be very simple

what do I know I imagine

PRINT oPrn NAME "My Print" CALCULATE

I execute two times the same function the firs is only for calculation the second really prints

have a nice day

Marco Boschi
info@marcoboschi.it
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: Calculate total pages

Posted: Wed Nov 22, 2023 08:56 PM

I have the same problem on treport

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 03:32 PM

Marco Boschi, I don't understand what you want to do exactly. Can you explain in more detail? Do you want to control page skipping?

Marco Boschi, no entiendo qué quieres hacer exactamente. ¿Puedes explicarlo con más detalle? ¿Quieres controlar el salto de página?

Gracias, thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 04:04 PM

Marco,

with the tprinter class it is easy to calculate the number of pages, just set how many rows you want per sheet and then divide the total archive with the rows and you will have the number of pages, but with the treport class I cannot do it, that is, it is displayed to me the page number but not the total number of pages and I can't know this before printing the pages.

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 04:48 PM

Silvio, I don't understand, what is the reason for knowing in advance how many pages the report has? If it's not inconvenient, can you explain it to me?

Silvio, no entiendo, ¿cuál es la razón para saber de antemano cuántas páginas tiene el informe? Si no es inconveniente, ¿puedes explicármelo?

Gracias, thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 05:58 PM

It is required for printing something like this in each page:

Page no. x of y

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 06:51 PM

Enrico,

here's how I do it: I save an emf file and then reopen add the number and print it.

I use it for invoice copies, I print the invoice number on the emf and then print on paper.

Strictly speaking, regenerating from data is not a copy. In terms of financial regulations,

a blueprint is considered a copy.

Best regards,

Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 06:54 PM
Otto wrote:Enrico,
here's how I do it: I save an emf file and then reopen add the number and print it.
How to do that exactly? Can you share it?
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 08:13 PM
Enrico,
I have extended TPrinter.
Best regards,
Otto
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define HORZSIZE          4
#define VERTSIZE          6
#define HORZRES           8
#define VERTRES          10


//----------------------------------------------------------------------------//

INIT PROCEDURE XPrinterInit
    
    EXTEND CLASS TPrinter WITH METHOD xImportWMF
    
return

//----------------------------------------------------------------------------//

static function xImportWMF( cFile, lPlaceable, oRechnung, lLastPage )
    
    local Self     := HB_QSelf()
    
    local hMeta, hOld, hWMF
    local aData := PrnGetSize( ::hDC )
    local aInfo := Array( 5 )
    local cEndText := ""
    local oPrnFont, oPrnFont2
    //RKSV
    local nRow := 0
    local cDst := ""
    local aQRCodePosition := { 0,0,0,0 }
    local cDepRgNr := ""
    *----------------------------------------------------------
    
    
    
    //  local cBmpFile := "c:\xwinhotel\qrtemp.bmp"
    
    if oRechnung:nBARZHG <> 0
        cEndText := "BAR " + ALLTRIM( transform( oRechnung:nBARZHG,"99,999.99" ) )
    endif
    if oRechnung:nKARTE <> 0
        cEndText := cEndText + " " + ALLTRIM( oRechnung:cCREDITCARD)
    endif
    if oRechnung:nKREDIT <> 0
        cEndText := cEndText + "  KRE. " +  ALLTRIM( transform(oRechnung:nKREDIT,"99,999.99"))
    endif
    if oRechnung:nSCHECK <> 0
        cEndText := cEndText + "  SCHECK " +  ALLTRIM( transform(oRechnung:nSCHECK,"99,999.99"))
    endif
    
    cEndText := cEndText + " " + oRechnung:cUSERName
    
    DEFAULT lPlaceable := .T.
    
    if ! File( cFile )
    return nil
endif

SaveDC( ::hDCOut )

#ifdef __CLIPPER__
if lPlaceable
    hMeta := GetPMetaFile( cFile, aInfo )
else
    hMeta := GetMetaFile( cFile )
endif
#else
if Upper( cFileExt( cFile ) ) == "EMF"
    hMeta := GetEnhMetaFile( cFile )
else
    hOld = GetPMetaFile( cFile, aInfo )
    hMeta = WMF2EMF( hOld, ::hDCOut )
endif
#endif

::SetIsoTropicMode()
::SetWindowExt( GetDeviceCaps( ::hDC, HORZRES ),;
    GetDeviceCaps( ::hDC, VERTRES ) ) //  aData[ 1 ], aData[ 2 ] )
::SetViewPortExt( GetDeviceCaps( ::hDC, HORZRES ),;
    GetDeviceCaps( ::hDC, VERTRES ) ) //  aData[ 1 ], aData[ 2 ] )

if ! ::lMeta
    SetViewOrg( ::hDCOut, -::nXoffset, -::nYoffset )
endif

SetBkMode( ::hDCOut, 1 )

if Upper( cFileExt( cFile ) ) == "EMF"
    
    PlayEnhMetafile( ::hDCOut, hMeta,, .t. )
    
    //----------------------------------------------------------------------------//
    DEFINE FONT oPrnFont    NAME "Arial" SIZE 17 * ( ::nHorzRes()/2400), 50*(::nVertRes()/3250) // FNTNORMAL
    DEFINE FONT oPrnFont2   NAME "Arial" SIZE Setup():nFntZHG * ( ::nHorzRes()/2400), 30 * (::nVertRes()/3250) * + ( Setup():nFntZHG/10 ) // FNTNORMAL
    
    cDepRgNr :=   Setup():KassenID  +"-" + ALLTRIM( oRechnung:cFLDNR_DEP  )+"-" + ALLTRIM(str(oRechnung:nRgNr))  
    
    if UPPER( right( cFile, 5 ) ) = "1.EMF"
        ::CmSay( Setup():RgNr_ROW, Setup():RgNr_COL, cDepRgNr  + "  - Kopie", oPrnFont  )
        
    else
        ::CmSay( Setup():RgNr_ROW2, Setup():RgNr_COL2, cDepRgNr + "  - Kopie", oPrnFont  )
        
    endif
    
    
    if lLastPage = .t.
        
        ::CmSay( Setup():EndTXT_ROW,     Setup():EndTXT_COL,     "Bezahlt: " + cEndText, oPrnFont2  ) //Zahlungsart
        
    
        ::CmSay( Setup():Aufteilung_ROW, Setup():Aufteilung_COL, "Erlösauft: " + oRechnung:Erloesaufteilung(), oPrnFont  )
        
        cDst  := Setup():cRKSVPfad  + "\" + ALLTRIM( Setup():KassenID )+ "\QR\qr" + ALLTRIM( oRechnung:cFLDNR_DEP  ) + ".bmp"
        
        //Lesen der QRCode-position
        aQRCodePosition[1] := VAL( GetPvProfString( "QRCodePosition" , "Top",       "5000",  ".\ini\RunTime.ini" ) )
        aQRCodePosition[2] := VAL( GetPVProfString( "QRCodePosition" , "Left",      "100",  ".\ini\RunTime.ini" ) )
        aQRCodePosition[3] := VAL( GetPVProfString( "QRCodePosition" , "nWidth",    "700",  ".\ini\RunTime.ini" ) )
        aQRCodePosition[4] := VAL( GetPVProfString( "QRCodePosition" , "nHeight",   "700",  ".\ini\RunTime.ini" ) )
        
        ::SayBitmap( aQRCodePosition[1], aQRCodePosition[2], cDst, aQRCodePosition[3], aQRCodePosition[4] )  
        
        //  nRow   := Setup():Aufteilung_ROW - 500
        //  ::SayBitmap( 500, 1000, cBmpFile, 600, 600 )
        
        
    endif
    
    release oPrnFont
    release oPrnFont2
    
    //----------------------------------------------------------------------------//
    
else
    PlayMetaFile( ::hDCOut, hWMF := EMF2WMF( hMeta, ::hDCOut ) )
    DeleteMetafile( hWMF )
endif




DeleteEnhMetafile( hMeta )

if ! Empty( hOld )
    DeleteMetafile( hOld )
endif

RestoreDC( ::hDCOut )

return nil

//----------------------------------------------------------------------------//
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 09:25 PM

Than you, but I can't find nothing related to total number of pages, or I am missing it. Can you explain?

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 09:36 PM

Enrico, I use it for a different purpose. But you only need to count the number of EMF files per document.

Then you can print the pages and write whatever you want on them as if on a layer.

Best regards,

Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Calculate total pages

Posted: Thu Nov 23, 2023 09:40 PM

Thank you. It is not worth the work, at least for me.

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: Calculate total pages

Posted: Fri Nov 24, 2023 08:46 AM

For TPrinter there is :

  • New: Method GetPages() on class TPrinter to get the From & To pages

selected on the print dialog when the FROM USER clause is used.

This method returns a two dimension array but also you can pass the

nFrom and nTo variables by reference, for example:

aPages := oPrn:GetPages(@nFrom, @nTo)

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM

Re: Calculate total pages

Posted: Fri Nov 24, 2023 12:11 PM
Enrico Maria Giordano wrote:It is required for printing something like this in each page:

Page no. x of y
Marco Boschi
info@marcoboschi.it
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Calculate total pages

Posted: Fri Nov 24, 2023 12:57 PM

Mister Otto, any practical example of this madness you posted?

Señor Otto, ¿algún ejemplo práctico de esta locura que publicó?

Gracias, thanks.

Regrards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341