Calculate total pages

User avatar
MarcoBoschi
Posts: 1070
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Calculate total pages

Post by MarcoBoschi »

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
User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate total pages

Post by Silvio.Falconi »

I have the same problem on treport
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Calculate total pages

Post by karinha »

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
User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate total pages

Post by Silvio.Falconi »

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 November 2023 - January 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
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Calculate total pages

Post by karinha »

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
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Calculate total pages

Post by Enrico Maria Giordano »

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

Page no. x of y
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Calculate total pages

Post by Otto »

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Calculate total pages

Post by Enrico Maria Giordano »

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?
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Calculate total pages

Post by Otto »

Enrico,
I have extended TPrinter.
Best regards,
Otto

Code: Select all | Expand


#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

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

********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Calculate total pages

Post by Enrico Maria Giordano »

Than you, but I can't find nothing related to total number of pages, or I am missing it. Can you explain?
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Calculate total pages

Post by Otto »

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Marc Venken
Posts: 1481
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Calculate total pages

Post by Marc Venken »

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
User avatar
MarcoBoschi
Posts: 1070
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Calculate total pages

Post by MarcoBoschi »

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
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Calculate total pages

Post by karinha »

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
Post Reply