// C:\FWH...\SAMPLES\DAMIANO.PRG
Code: Select all
#Include "FiveWin.ch"
FUNCTION Main()
LOCAL cComeFrom := "With preview"
// oPrn:SetCopies( nCopie ) // Does not work
LOCAL nCopie := 1
nSetCopies( nCopie, cComeFrom ) // nCopies
RETURN NIL
FUNCTION nSetCopies( nCopie, cComeFrom )
LOCAL nI
FOR nI := 1 TO nCopie
MsgRun( "PREVIEW. WAIT...", ;
"Wait a Moment... ", ;
{ || CursorWait(), WinExec( Imp_Damiano( cComeFrom ) ), 3 } )
NEXT
RETURN NIL
FUNCTION Imp_Damiano( cComeFrom )
LOCAL aPrn, oPrn, oFont, oFont2, oFont3, m_Get := ARRAY(5)
LOCAL nRowStep, nColStep
m_Get[01] := DTOC( DATE() )
aPrn := GetPrinters()
IF Empty( aPrn )
RETURN NIL
ENDIF
PRINTER oPrn PREVIEW MODAL
IF EMPTY( oPrn:hDC )
oPrn:End()
RETURN( .F. )
ENDIF
oPrn:End()
IF cComeFrom = "Directtoprinter"
PRINT oPrn NAME "Cartellino finiti" // Direct to the printer
ELSEIF cComeFrom = "With preview"
PRINT oPrn NAME "Cartellino finiti" PREVIEW MODAL // With preview
ELSEIF cComeFrom = "GeneratePDF"
PRINT oPrn PREVIEW // Generate PDF
ENDIF
DEFINE FONT oFont NAME "Bahnschrift Light Condensed" SIZE 0, - 18 BOLD OF oPrn
DEFINE FONT oFont2 NAME "Bahnschrift Light Condensed" SIZE 0, - 26 BOLD OF oPrn
DEFINE FONT oFont3 NAME "Bahnschrift Light Condensed" SIZE 0, - 20 BOLD OF oPrn
nRowStep = oPrn:nVertRes() / 40 // 56 righe
nColStep = oPrn:nHorzRes() / 80 // 170 colonne
PAGE
oPrn:Say( nRowStep * 2, nColStep * 65, TRANSF( m_Get[01],"@D 99/99/9999" ), oFont3 ) //Data
ENDPAGE
ENDPRINT
IF cComeFrom = "GeneratePDF"
FWSavePreviewToPDF( oPrn, "Cartellino.pdf", .F. )
ENDIF
oFont:End()
oFont2:End()
oFont3:End()
RETURN NIL
Regards.