Page 1 of 1

PRINT without PREVIEW

Posted: Tue Mar 03, 2020 4:25 pm
by damianodec
HI,
when I use this code:

Code: Select all

    
 PRINT oPrn NAME "Cartellino finiti" PREVIEW
    
        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:SetCopies(nCopie)

    oPrn:Say(nRowStep * 2,nColStep * 65,Transform(m_get[01],"@ 99/99/9999"),oFont3) //Data
....
ENDPAGE
ENDPRINT
I get Preview window and then print the page.
but if I Use PRINT command without PREVIEW I get a empty page.
any help?

Re: PRINT without PREVIEW

Posted: Tue Mar 03, 2020 5:52 pm
by karinha
// 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.

Re: PRINT without PREVIEW

Posted: Wed Mar 04, 2020 7:47 am
by damianodec
it works
thank you!