Tamanho letra padrão com win_prn()

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Tamanho letra padrão com win_prn()

Mensagem por Itamar M. Lins Jr. »

Ola!
Estou querendo usar o tamanho draft, mas fica pouca coisa maior.
Por isso está cortando no final, um pedaço da letra/numero quando uso por exemplo
replicate("-",79)

Código: Selecionar todos

oPrn : setfont('Courier New',,10,,,,255)
Em alguns modelos fica ok, em outras corta um pouco.
Alguém pode compartilhar/ensinar/melhorar esse código ?

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Kapiaba
Colaborador
Colaborador
Mensagens: 1908
Registrado em: 07 Dez 2012 16:14
Localização: São Paulo
Contato:

Tamanho letra padrão com win_prn()

Mensagem por Kapiaba »

Olá, veja se ajuda:

Código: Selecionar todos

#define  RGB_BLACK       RGB(   0,  0,  0 )
#define  RGB_RED         RGB( 255,  0,  0 )
#define  RGB_GREEN       RGB(   0,255,  0 )
#define  RGB_BLUE        RGB(   0,  0,255 )
#define  RGB_CYAN        RGB(   0,255,255 )
#define  RGB_YELLOW      RGB( 255,255,  0 )
#define  RGB_MAGENTA     RGB( 255,  0,255 )
#define  RGB_WHITE       RGB( 255,255,255 )
 
#define FW_DONTCARE    0
#define FW_THIN        100
#define FW_EXTRALIGHT  200
#define FW_LIGHT       300
#define FW_NORMAL      400
#define FW_MEDIUM      500
#define FW_SEMIBOLD    600
#define FW_BOLD        700
#define FW_EXTRABOLD   800
#define FW_HEAVY       900
#define DMPAPER_A4                             9
 
FUNCTION Test2(cPrn)
 
   LOCAL oPrinter
   LOCAL aFonts, cFont, nFont
 
   oPrinter           := Win32Prn():new( cPrn) // Create printer object and configure print job
   oPrinter:landscape := .F.
   oPrinter:formType  := DMPAPER_A4
   oPrinter:copies    := 2                     // <--- 2 copies !!
 
   IF .NOT. oPrinter:create()                  // Create device context
 
      Alert( "Nao Foi Possivel Criar o Contexto de Dispositivo" )
 
      QUIT
 
   ENDIF
 
   IF .NOT. oPrinter:startDoc( "xHarbour Teste de Pagina" ) // Create print job
 
      Alert( "Nao Foi Possivel Criar o Documento" )
 
      QUIT
 
   ENDIF
 
   oPrinter:textOut( "Texto em Fonte Padrao" ) // Text in fixed font
   oPrinter:bold( FW_EXTRABOLD )
   oPrinter:textOut( oPrinter:fontName )
   oPrinter:bold( FW_NORMAL )
   oPrinter:newLine()
 
   aFonts := oPrinter:getFonts()

   nFont  := AScan( aFonts, ;
                    {|a| "COURIER NEW" $ Upper(a[1]) } )

   cFont  := aFonts[nFont,1]
 
   oPrinter:setFont( cFont )                       // Text in proportional font
   oPrinter:textOut( "Texto em Fonte Courier: " )
   oPrinter:bold( FW_EXTRABOLD )
   oPrinter:textOut( oPrinter:fontName )
   oPrinter:bold( FW_NORMAL )
   oPrinter:newLine()
 
   oPrinter:setColor( RGB_YELLOW, RGB_BLUE )    // Colored text
   oPrinter:textOut( "Amarelo no Azul - Yellow on Blue " )
   oPrinter:newLine()
 
   oPrinter:setPen( PS_DASH, 5, RGB_GREEN )    // Draw colored line across page
   oPrinter:line( oPrinter:posX, ;
                  oPrinter:posY, ;
                  oPrinter:rightMargin, ;
                  oPrinter:posY  )
 
   oPrinter:endDoc()       // Send output to printer
   oPrinter:destroy()      // Release GDI device context
 
RETURN NIL
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Tamanho letra padrão com win_prn()

Mensagem por Itamar M. Lins Jr. »

Infelizmente não ajuda.
É apenas na linha em questão.
Eu tenho o código comprimido

Código: Selecionar todos

oPrn:SetFont( "Courier New", 7, { 3, -50 } )
Tem as variações ai no -50...
Pode ser o espaçamento, mas terei que olhar no fonte, queria poupar esse trabalho.

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Kapiaba
Colaborador
Colaborador
Mensagens: 1908
Registrado em: 07 Dez 2012 16:14
Localização: São Paulo
Contato:

Tamanho letra padrão com win_prn()

Mensagem por Kapiaba »

https://github.com/harbour/core/blob/ma ... s/prn1.prg

Código: Selecionar todos

// PRN1.PRG

#require "hbwin"

PROCEDURE Main( cPar1 )

   LOCAL nPrn := 1
   LOCAL cBMPFile := Space( 40 )
   LOCAL GetList := {}

   LOCAL aPrn := win_printerList()

   IF Empty( aPrn )
      Alert( "No printers installed - Cannot continue" )
   ELSE
      DO WHILE nPrn != 0
         CLS
         @ 0, 0 SAY "win_Prn() Class test program. Choose a printer to test"
         @ 1, 0 SAY "Bitmap file name:" GET cBMPFile PICT "@K"
         READ
         @ 2, 0 TO MaxRow(), MaxCol()
         nPrn := AChoice( 3, 1, MaxRow() - 1, MaxCol() - 1, aPrn, .T.,, nPrn )
         IF nPrn != 0
            PrnTest( aPrn[ nPrn ], cBMPFile, iif( HB_ISSTRING( cPar1 ) .AND. Lower( cPar1 ) == "ask", .T., NIL ) )
         ENDIF
      ENDDO
   ENDIF

   RETURN

STATIC PROCEDURE PrnTest( cPrinter, cBMPFile, lAsk )

   LOCAL oPrinter := win_Prn():New( cPrinter )
   LOCAL aFonts
   LOCAL x
   LOCAL nColFixed
   LOCAL nColTTF
   LOCAL nColCharSet

   oPrinter:Landscape := .F.
   oPrinter:FormType  := WIN_DMPAPER_A4
   oPrinter:Copies    := 1
   IF HB_ISLOGICAL( lAsk )
      oPrinter:AskProperties := lAsk
   ENDIF

   IF ! oPrinter:Create()
      Alert( "Cannot Create Printer" )
   ELSE
      IF ! oPrinter:startDoc( "win_Prn(Doc name in Printer Properties)" )
         Alert( "StartDoc() failed" )
      ELSE
         oPrinter:SetPen( WIN_PS_SOLID, 1, HB_WIN_RGB_RED )
         oPrinter:Bold( WIN_FW_EXTRABOLD )
         oPrinter:TextOut( oPrinter:PrinterName + ": MaxRow() = " + hb_ntos( oPrinter:MaxRow() ) + "   MaxCol() = " + hb_ntos( oPrinter:MaxCol() ) )
         oPrinter:Bold( WIN_FW_DONTCARE )
         oPrinter:NewLine()
         oPrinter:TextOut( "   Partial list of available fonts that are available for OEM_" )
         oPrinter:NewLine()
         oPrinter:UnderLine( .T. )
         oPrinter:Italic( .T. )

//       oPrinter:SetFont( "Courier New", 7, { 3, -50 } )  // Compressed print

         nColFixed   := 40 * oPrinter:CharWidth
         nColTTF     := 48 * oPrinter:CharWidth
         nColCharSet := 60 * oPrinter:CharWidth
         oPrinter:TextOut( "FontName" )
         oPrinter:SetPos( nColFixed )
         oPrinter:TextOut( "Fixed?" )
         oPrinter:SetPos( nColTTF )
         oPrinter:TextOut( "TrueType?" )
         oPrinter:SetPos( nColCharset )
         oPrinter:TextOut( "CharSet#", .T. )
         oPrinter:NewLine()
         oPrinter:Italic( .F. )
         oPrinter:UnderLine( .F. )
         aFonts := oPrinter:GetFonts()
         oPrinter:NewLine()
         FOR x := 1 TO Len( aFonts ) STEP 2
            oPrinter:CharSet( aFonts[ x, 4 ] )
            IF oPrinter:SetFont( aFonts[ x, 1 ] )       // Could use "IF oPrinter:SetFontOk" after call to oPrinter:SetFont()
               IF oPrinter:FontName == aFonts[ x, 1 ]  // Make sure Windows didn't pick a different font
                  oPrinter:TextOut( aFonts[ x, 1 ] )
                  oPrinter:SetPos( nColFixed )
                  oPrinter:TextOut( iif( aFonts[ x, 2 ], "Yes", "No" ) )
                  oPrinter:SetPos( nColTTF )
                  oPrinter:TextOut( iif( aFonts[ x, 3 ], "Yes", "No" ) )
                  oPrinter:SetPos( nColCharSet )
                  oPrinter:TextOut( hb_ntos( aFonts[ x, 4 ] ) )
                  oPrinter:SetPos( oPrinter:LeftMargin, oPrinter:PosY + ( oPrinter:CharHeight * 2 ) )
                  IF oPrinter:PRow() > oPrinter:MaxRow() - 16  // Could use "oPrinter:NewPage()" to start a new page
                     EXIT
                  ENDIF
               ENDIF
            ENDIF
            oPrinter:Line( 0, oPrinter:PosY + 5, 2000, oPrinter:PosY + 5 )
         NEXT
         oPrinter:SetFont( "Lucida Console", 8, { 3, -50 } )  // Alternative Compressed print
         oPrinter:CharSet( 0 )  // Reset default charset
         oPrinter:Bold( WIN_FW_EXTRABOLD )
         oPrinter:NewLine()
         oPrinter:TextOut( "This is on line" + hb_ntos( oPrinter:PRow() ) + ", Printed bold, " )
         oPrinter:TextOut( " finishing at Column: " )
         oPrinter:TextOut( hb_ntos( oPrinter:PCol() ) )
         oPrinter:SetPRC( oPrinter:PRow() + 3, 0 )
         oPrinter:Bold( WIN_FW_DONTCARE )
         oPrinter:TextOut( "Notice: UNDERLINE only prints correctly if there is a blank line after", .T. )
         oPrinter:TextOut( "        it. This is because of :LineHeight and the next line", .T. )
         oPrinter:TextOut( "        printing over top of the underline. To avoid this happening", .T. )
         oPrinter:TextOut( "        you can to alter :LineHeight or use a smaller font, or use :SetBkMode( WIN_TRANSPARENT )" )
         oPrinter:NewLine()
         oPrinter:NewLine()
         oPrinter:SetFont( "Lucida Console", 18, 0 )  // Large print
         oPrinter:SetColor( HB_WIN_RGB_GREEN )
         oPrinter:TextOut( "Finally some larger print" )
         oPrinter:Box(   0, oPrinter:PosY + 100, 100, oPrinter:PosY + 200 )
         oPrinter:Arc( 200, oPrinter:PosY + 100, 300, oPrinter:PosY + 200 )
         oPrinter:Ellipse( 400, oPrinter:PosY + 100, 500, oPrinter:PosY + 200 )
         oPrinter:FillRect( 600, oPrinter:PosY + 100, 700, oPrinter:PosY + 200, HB_WIN_RGB_RED )

         // To print a barcode;
         // Replace "BCod39HN" with your own bar code font or any other font
         //   oPrinter:TextAtFont( oPrinter:MM_TO_POSX( 30 ), oPrinter:MM_TO_POSY( 60 ), "1234567890", "BCod39HN", 24, 0 )
         //
         PrintBitmap( oPrinter, cBMPFile )

         oPrinter:EndDoc()
      ENDIF
      oPrinter:Destroy()
   ENDIF

   RETURN

STATIC PROCEDURE PrintBitmap( oPrn, cBitFile )

   LOCAL oBMP

   IF ! Empty( cBitFile )
      IF hb_FileExists( cBitFile )
         oBMP := win_BMP():New()
         IF oBmp:loadFile( cBitFile )

            oBmp:Draw( oPrn, { 200, 200, 2000, 1500 } )
#if 0
            /* Note: Can also use this method to print bitmap */
            oBmp:Rect := { 200, 200, 2000, 1500 }
            oPrn:DrawBitmap( oBmp )
#endif
         ENDIF
         oBMP:Destroy()
      ELSE
         Alert( hb_StrFormat( "%1$s not found ", cBitFile ) )
      ENDIF
   ENDIF

RETURN
Kapiaba
Colaborador
Colaborador
Mensagens: 1908
Registrado em: 07 Dez 2012 16:14
Localização: São Paulo
Contato:

Tamanho letra padrão com win_prn()

Mensagem por Kapiaba »

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Tamanho letra padrão com win_prn()

Mensagem por Itamar M. Lins Jr. »

Ok!, deixe pra lá isso.
Eu já tinha visto todos esses códigos...
Enfim terei que ir no cliente testar na impressora em questão.
Se tive sucesso postarei a linha com esse código. É uma linha só.

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Responder