Calculate total pages

Calculate total pages

Postby MarcoBoschi » Wed Nov 22, 2023 5: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
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Calculate total pages

Postby Silvio.Falconi » Wed Nov 22, 2023 8: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 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
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate total pages

Postby karinha » Thu Nov 23, 2023 3: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
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Calculate total pages

Postby Silvio.Falconi » Thu Nov 23, 2023 4: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 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
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate total pages

Postby karinha » Thu Nov 23, 2023 4: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
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Calculate total pages

Postby Enrico Maria Giordano » Thu Nov 23, 2023 5:58 pm

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

Page no. x of y
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Calculate total pages

Postby Otto » Thu Nov 23, 2023 6: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Calculate total pages

Postby Enrico Maria Giordano » Thu Nov 23, 2023 6: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?
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Calculate total pages

Postby Otto » Thu Nov 23, 2023 8:13 pm

Enrico,
I have extended TPrinter.
Best regards,
Otto

Code: Select all  Expand view


#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
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Calculate total pages

Postby Enrico Maria Giordano » Thu Nov 23, 2023 9:25 pm

Than you, but I can't find nothing related to total number of pages, or I am missing it. Can you explain?
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Calculate total pages

Postby Otto » Thu Nov 23, 2023 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Calculate total pages

Postby Enrico Maria Giordano » Thu Nov 23, 2023 9:40 pm

Thank you. It is not worth the work, at least for me.
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Calculate total pages

Postby Marc Venken » Fri Nov 24, 2023 8: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Calculate total pages

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

Re: Calculate total pages

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests