Page 1 of 3
Calculate total pages
Posted: Wed Nov 22, 2023 5:31 pm
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
Re: Calculate total pages
Posted: Wed Nov 22, 2023 8:56 pm
by Silvio.Falconi
I have the same problem on treport
Re: Calculate total pages
Posted: Thu Nov 23, 2023 3:32 pm
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.
Re: Calculate total pages
Posted: Thu Nov 23, 2023 4:04 pm
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.
Re: Calculate total pages
Posted: Thu Nov 23, 2023 4:48 pm
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.
Re: Calculate total pages
Posted: Thu Nov 23, 2023 5:58 pm
by Enrico Maria Giordano
It is required for printing something like this in each page:
Page no. x of y
Re: Calculate total pages
Posted: Thu Nov 23, 2023 6:51 pm
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
Re: Calculate total pages
Posted: Thu Nov 23, 2023 6:54 pm
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?
Re: Calculate total pages
Posted: Thu Nov 23, 2023 8:13 pm
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
//----------------------------------------------------------------------------//
Re: Calculate total pages
Posted: Thu Nov 23, 2023 9:25 pm
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?
Re: Calculate total pages
Posted: Thu Nov 23, 2023 9:36 pm
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
Re: Calculate total pages
Posted: Thu Nov 23, 2023 9:40 pm
by Enrico Maria Giordano
Thank you. It is not worth the work, at least for me.
Re: Calculate total pages
Posted: Fri Nov 24, 2023 8:46 am
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)
Re: Calculate total pages
Posted: Fri Nov 24, 2023 12:11 pm
by MarcoBoschi
Enrico Maria Giordano wrote:It is required for printing something like this in each page:
Page no. x of y
Re: Calculate total pages
Posted: Fri Nov 24, 2023 12:57 pm
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.