Landscape print is not correct

Landscape print is not correct

Postby Ugo » Thu Dec 29, 2005 1:29 pm

Hi fw's
with the fwh 2.7 version I have a problem in landscape print.

This problem is not present in previous version FWH2.5

Test this sample:
Code: Select all  Expand view
#include "Fivewin.ch"

FUNCTION Main()

   Stampa( 0, "Prova Verticale" )
   Stampa( 1, "Prova Orizzontale" )

   RETURN Nil

FUNCTION Stampa( nOriente, cTitolo )

   LOCAL oFont
   LOCAL oPrinter

   DEFAULT cTitolo := "Prova Orizzontale", nOriente := 1

   // Qui imposto la stampa da fivewin
   PRINT oPrinter PREVIEW // NAME cTxt MODAL // TO cPrinter

   IF oPrinter:hDC != 0

      DEFINE Font oFont NAME "Arial" SIZE 0, - 20 BOLD OF oPrinter

      PAGE

      IF nOriente > 0
         oPrinter:SetLandscape()
      ELSE
         oPrinter:SetPortrait()
      ENDIF

      oPrinter:CmSay( 1, 1, cTitolo, oFont )

      ENDPAGE
      ENDPRINT

      oFont:END()

   ENDIF
   RETURN .t.
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: Landscape print is not correct

Postby Enrico Maria Giordano » Thu Dec 29, 2005 1:39 pm

What is exactly the problem? I can't see it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8242
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Landscape print is not correct

Postby Ugo » Thu Dec 29, 2005 1:56 pm

EnricoMaria wrote:What is exactly the problem? I can't see it


Enrico,
the font and any object is not the same in landscape;
please test this:
Code: Select all  Expand view
#include "Fivewin.ch"

#xtranslate  NTRIM( < n > ) = > ( LTrim( Str( < n > ) ) )

#xtranslate  MM2PxHor( < nMM >, < oPrn > ) = > < nMM > / 25.4 * < oPrn > :nLogPixelX()
#xtranslate  MM2PxVer( < nMM >, < oPrn > ) = > < nMM > / 25.4 * < oPrn > :nLogPixelY()
#xtranslate  Px2MMVer( < nPx >, < oPrn > ) = > < nPx > * 25.4 / < oPrn > :nLogPixelY()

FUNCTION Main()

   Stampa( 0, "Prova Verticale" )
   Stampa( 1, "Prova Orizzontale" )

   RETURN Nil

FUNCTION Stampa( nOriente, cTitolo )

   LOCAL nZ, aTabul
   LOCAL oFont, Font, nTmp, cTxt
   LOCAL oPen, oPen1, oPen2, nPag, aParam := { }, aCorpo
   LOCAL oPrinter, nPosRow, nPosCol, nMax, nCol

   DEFAULT cTitolo := "Prova Orizzontale", nOriente := 1

   nPag := 0

   aTabul := { { "Colonna 1", 0,   8, 53, 1 }, ;
               { "Colonna 2", 0,  63, 60, 3 }, ;
               { "Colonna 3", 0, 125, 65, 5 } }

   // Qui imposto la stampa da fivewin
   PRINT oPrinter PREVIEW // NAME cTxt MODAL // TO cPrinter

   IF oPrinter:hDC != 0

      oFont := { }
      DEFINE Font Font NAME "Arial" SIZE 0, - 20 BOLD OF oPrinter
      AAdd( oFont, Font )

      DEFINE Font Font NAME "Arial" SIZE 0, - 9 BOLD OF oPrinter
      AAdd( oFont, Font )

      DEFINE Font Font NAME "Arial" SIZE 0, - 9 OF oPrinter
      AAdd( oFont, Font )

      SysRefresh()

      PAGE

      IF nOriente > 0
         oPrinter:SetLandscape()
      ELSE
         oPrinter:SetPortrait()
      ENDIF

      SysRefresh()

      aParam := oPrinter:GetPhySize()
      AAdd( aParam, 15 )
      AAdd( aParam, 10 )
      AAdd( aParam, 25 )
      AAdd( aParam,  5 )

      DEFINE PEN  oPen  WIDTH   1    OF oPrinter
      DEFINE PEN  oPen1 WIDTH  10    OF oPrinter
      DEFINE PEN  oPen2 WIDTH  15    OF oPrinter

      aCorpo   := Array( 2 )
      nCol     := Len( aTabul )
      nMax     := 0
      nTmp     := 0
      nPosRow  := 15
      nPosCol  := 10

      oPrinter:Say( MM2PxVer( nPosRow, oPrinter ), ;
                    MM2PxHor( nPosCol, oPrinter ), ;
                    cTitolo, oFont[ 1 ] )

      nPosRow += Px2MMVer( oFont[ 1 ]:nHeight, oPrinter ) + aParam[ 6 ]
      nMax    := 0
      FOR nZ := 1 TO nCol
         nTmp := MM2PxVer( nPosRow, oPrinter ) + aTabul[ nZ, 2 ] * oFont[ 2 ]:nHeight * 1.2
         IF nMax < nTmp
            nMax := nTmp
         ENDIF
         oPrinter:Say( nTmp, ;
                       MM2PxHor( ( nPosCol + aTabul[ nZ, 3 ] ), oPrinter ), ;
                       aTabul[ nZ, 1 ], oFont[ 2 ] )
      NEXT
      aCorpo[ 1 ] := nMax + oFont[ 2 ]:nHeight * 1.2
      oPrinter:Line( aCorpo[ 1 ], ;
                     MM2PxHor( ( aParam[ 4 ] ), oPrinter ), ;
                     aCorpo[ 1 ], ;
                     MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ), ;   
                     oPen1 )
      aCorpo[ 1 ] += oFont[ 2 ]:nHeight * 0.2

      aCorpo[ 2 ] := MM2PxVer( ( aParam[ 2 ] - aParam[ 5 ] ), oPrinter )
      oPrinter:Line( aCorpo[ 2 ], ;
                     MM2PxHor( ( aParam[ 4 ] ), oPrinter ), ;
                     aCorpo[ 2 ], ;
                     MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ), ;   
                     oPen2 )
      aCorpo[ 2 ] -= oFont[ 2 ]:nHeight * 1.2
      cTxt := "Pagina " + NTrim( nPag )
      oPrinter:Say( aCorpo[ 2 ] + oFont[ 3 ]:nHeight * 1.5, ;
                    MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ) - oPrinter:GetTextWidth( cTxt, oFont[ 3 ] ), ;
                    cTxt, oFont[ 3 ] )
      cTxt := "Torino, " + " " + DToC( Date() )
      oPrinter:Say( aCorpo[ 2 ] + oFont[ 3 ]:nHeight * 1.5, ;
                    MM2PxHor( nPosCol, oPrinter ), ;
                    cTxt, oFont[ 3 ] )

      EndPage
      ENDPRINT
      oPen:END()
      oPen1:END()
      oPen2:END()

      oFont[ 1 ]:END()
      oFont[ 2 ]:END()
      oFont[ 3 ]:END()
   ENDIF
   RETURN .t.[\code]
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: Landscape print is not correct

Postby Enrico Maria Giordano » Thu Dec 29, 2005 2:10 pm

Move

Code: Select all  Expand view
IF nOriente > 0
   oPrinter:SetLandscape()
ELSE
   oPrinter:SetPortrait()
ENDIF


just before the font definition.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8242
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Landscape print is not correct

Postby Ugo » Thu Dec 29, 2005 2:14 pm

EnricoMaria wrote:Move

Code: Select all  Expand view
IF nOriente > 0
   oPrinter:SetLandscape()
ELSE
   oPrinter:SetPortrait()
ENDIF


just before the font definition.

EMG


Now work,
thank you.
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy


Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 6 guests