Página 1 de 1

Imprimir Texto com fundo cinza

Enviado: 01 Jun 2012 16:53
por locio
No codigo abaixo consigo fazer tom de cinza, mas gostaria de :

1 - Imprimir o Texto com a fonte preta com o fundo cinza e tá saindo o texto com a fonte preta e o fundo em branco;

2 - o tom de cinza que eu consegui é muito intenso como faço para conseguir um cinza mais brando, tipo 25% do que eu conseguir.

Código: Selecionar todos


#define FORM_A4 9
#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) ) 
#define PS_SOLID   0 
#define BLACK           RGB( 0x0 ,0x0 ,0x0 ) 
#define BLUE            RGB( 0x0 ,0x0 ,0x85 ) 
#define GREEN           RGB( 0x0 ,0x85,0x0 ) 
#define CYAN            RGB( 0x0 ,0x85,0x85 ) 
#define RED             RGB( 0x85,0x0 ,0x0 ) 
#define MAGENTA         RGB( 0x85,0x0 ,0x85 ) 
#define BROWN           RGB( 0x85,0x85,0x0 ) 
#define WHITE           RGB( 0xC6,0xC6,0xC6 )
#define CINZA           RGB( 0x88 ,0x88 ,0x88 ) 

*
*--------------------------------------------------------------------------------------
FUNCTION Main()

  LOCAL nPrn:=1
  LOCAL aPrn:= GetPrinters()

  REQUEST HB_CODEPAGE_PT850
  HB_SetCodePage( "PT850" )


  CLS
  IF EMPTY(aPrn)
    Alert("No printers installed - Cannot continue")
    QUIT
  ENDIF


  DO WHILE !EMPTY(nPrn)
    CLS
    @ 0,0 SAY 'Programa de teste Classe WIN32PRN(). Escolha uma impressora. ESC' +;
              ' para sair.'
    @ 1,0 TO maxRow(),maxCol()
    nPrn:= ACHOICE(2,1,maxRow()-1,maxCol()-1,aPrn,.T.,,nPrn)
    IF !EMPTY(nPrn)
      PrnTest(aPrn[nPrn])
    ENDIF
  ENDDO

  *
  @ 22,00 say ""
  RETURN(NIL)


*
*--------------------------------------------------------------------------------------
STATIC FUNCTION PrnTest(cPrinter)
   LOCAL oPrinter:= WIN32PRN():New(cPrinter), aFonts, x, nColFixed, nColTTF, ;
                    nColCharSet, aForms

   oPrinter:Landscape:= .F.
   oPrinter:FormType := FORM_A4
   oPrinter:Copies   := 1

   oprinter:SetPrintQuality(-1) // qualidade da impressão


   IF !oPrinter:Create()
      Alert("Cannot Create Printer")
   ELSE
      IF !oPrinter:startDoc( )
           Alert("StartDoc() failed")
      ELSE

         oprinter:LineHeight := int(oprinter:PixelsPerInchy/8)

    
         oPrinter:NewPage()
         oPrinter:NewLine()
         oPrinter:NewLine()


         oPrinter:SetFont('Courier New',12,{1,12}, 0, .F., .F.)

         oPrinter:Box(  100,   100,  2350, 300 )
         oPrinter:Box(  2350,  100,  4700, 300 )

         oPrinter:FillRect(110,  110, 2340, 290, CINZA)
         oPrinter:FillRect(2350, 100, 4650, 290, CINZA)

         oPrinter:SetPrc( 03 , 10 )
         oPrinter:SetFont('ARIAL',9,{1,12}, 700, .F., .F.)
         oPrinter:TextOut(" LINHA 03 COL 10 " ,.T.)
         oPrinter:SetPrc( 03 , 50 )
         oPrinter:TextOut(" LINHA 03 COL 50 " ,.T.)


         oPrinter:EndDoc()

    ENDIF
    oPrinter:Destroy()
  ENDIF

RETURN(NIL)
*
*------------------------------------------------------------------------------

Obrigado

Lócio

Imprimir Texto com fundo cinza

Enviado: 01 Jun 2012 17:07
por Imatech
Tentativa e Erro...

#define CINZA RGB( 0x00, 0xFF, 0xFF )

Imprimir Texto com fundo cinza

Enviado: 01 Jun 2012 18:00
por locio
Fiz o teste. Ficou verde e não funciona para o fundo texto

Lócio

Imprimir Texto com fundo cinza

Enviado: 07 Jun 2012 22:08
por Hasse
Eu tenho um bom resultado com:

Código: Selecionar todos

#define GREY            RGB( 0xE6,0xE6,0xE6 )

Imprimir Texto com fundo cinza

Enviado: 08 Jun 2012 15:51
por locio
Ficou otimo o tom de cinza. Assim resolvo o cinza preenchendo o box. Você tem como fazer o texto com setcolor() imprimir com fonte negra e fundo cinza

Lócio

Imprimir Texto com fundo cinza

Enviado: 09 Jun 2012 14:09
por Hasse
Segue um pequeno módulo testado:

Código: Selecionar todos

*--------------------------------------------------------------------------------------
#define FORM_A4         9
*
#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) )
#define PS_SOLID        0
#define BLACK           RGB( 0x0 ,0x0 ,0x0 )
#define BLUE            RGB( 0x0 ,0x0 ,0x85 )
#define GREEN           RGB( 0x0 ,0x85,0x0 )
#define CYAN            RGB( 0x0 ,0x85,0x85 )
#define RED             RGB( 0x85,0x0 ,0x0 )
#define MAGENTA         RGB( 0x85,0x0 ,0x85 )
#define BROWN           RGB( 0x85,0x85,0x0 )
#define WHITE           RGB( 0xC6,0xC6,0xC6 )
#define GREY            RGB( 0xE6,0xE6,0xE6 )
#define BLANK           RGB( 255, 255 ,255  )
*
*--------------------------------------------------------------------------------------
FUNCTION Main()
  LOCAL nPrn:=1
  LOCAL aPrn:= GetPrinters()
  CLS
  IF EMPTY(aPrn)
    Alert("No printers installed - Cannot continue")
    QUIT
  ENDIF
  DO WHILE !EMPTY(nPrn)
    CLS
    @ 0,0 SAY 'Programa de teste Classe WIN32PRN(). Escolha uma impressora. ESC' +;
              ' para sair.'
    @ 1,0 TO maxRow(),maxCol()
    nPrn:= ACHOICE(2,1,maxRow()-1,maxCol()-1,aPrn,.T.,,nPrn)
    IF !EMPTY(nPrn)
      PrnTest(aPrn[nPrn])
    ENDIF
  ENDDO
  *
  @ 22,00 say ""
  RETURN(NIL)
*
*--------------------------------------------------------------------------------------
STATIC FUNCTION PrnTest( cPrinter )
   *
   LOCAL oPrinter:= WIN32PRN():New( cPrinter), aFonts, x, nColFixed, nColTTF, ;
                    nColCharSet, aForms
   oPrinter:Landscape := .F.
   oPrinter:FormType  := FORM_A4
   oPrinter:Copies    := 1
   oPrinter:SetPrintQuality(-4)
   *
   c_string := "Teste-" + LTRIM(STR(YEAR(DATE()))) + "-" + STRZERO(MONTH(DATE()),2) +;
                      "-" + LTRIM(STR(DAY(DATE()))) + "=" + TIME()
   *
   IF ! oPrinter:Create()
      Alert( "Cannot Create Printer" )
   ELSE
      IF !oPrinter:startDoc( c_string )
           Alert( "StartDoc() failed" )
      ELSE
         nFont := 20
         oPrinter:SetFont( 'Courier New', 10, { 1, nFont }, 0, .F., .F. )
    
         FOR N = 1 TO 2
            oPrinter:NewLine()
         NEXT N
         *
         *================================== Busca de informações =====================
         *
         oPrinter:TextOut("Impressora: " + oPrinter:PrinterName, .t.)
         oPrinter:TextOut('MaxRow() = '  + ltrim(STR(oPrinter:MaxRow(),4)) , .t.)
         oPrinter:TextOut('MaxCol() = '  + ltrim(STR(oPrinter:MaxCol(),4)) , .t.)
         *
         oPrinter:NewLine()
         oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)
         *      
         oPrinter:Textout(STR(oprinter:LineHeight()    ) + "  -altura da linha",.t.)
         oPrinter:Textout(STR(oprinter:CharWidth()     ) + "  -largura da coluna",.T.)
         oPrinter:TextOut(STR(oPrinter:Prow()          ) + "  -Número da linha",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharWidth()  ) + "  -GetCharWidth",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharHeight() ) + "  -GetCharHeigth",.T.)
         oPrinter:Textout(STR(oprinter:Prow()          ) + "  -Posição atual da " +;
                          "linha",.T.)
         *
         *         
         PrtRect( oPrinter )
         *
         oPrinter:EndDoc()
         oPrinter:Destroy()
         *
      ENDIF
      *
   ENDIF
   *
RETURN(NIL)
*
*
*--------------------------------------------------------------------------------------------------
PROCEDURE PrtRect( oPrinter )
*
oPrinter:Box(       9970, 1980, 30020, 15020 )
oPrinter:FillRect( 10000, 2000, 30000, 15000, GREY )
*
oPrinter:SetColor( BLACK , GREY )                     && cOR DO TEXTO.
*
oPrinter:TextOut( 'Texto de teste Texto de teste Texto de teste Texto de teste Texto de teste', .T. )
*
oPrinter:NewLine()
oprinter:setpos( (  61 * oPrinter:Charwidth ) );oprinter:textOut( "123456789012345678901234567890", .f. )
oprinter:setpos( (  92 * oPrinter:Charwidth ) );oprinter:textOut( [- Telefone], .f. )
oprinter:setpos( ( 103 * oPrinter:Charwidth ) );oprinter:textOut( [ 99  9999-9999], .f. )
oprinter:setpos( ( 118 * oPrinter:Charwidth ) );oprinter:textOut( [! Orcamento:], .f. )
oprinter:setpos( ( 132 * oPrinter:Charwidth ) );oprinter:textOut( [1234567], .f. )
oPrinter:NewLine()
*
nRow    := oPrinter:Prow() + 04
nCol    := 60
nAltLin := oPrinter:LineHeight()                         && Altura da linha.
nLarCar := oPrinter:GetCharWidth()                       && Largura da fonte em pixels.
nAltCar := oPrinter:GetCharHeight()                      && Altura da fonte em pixels.
*
*
*
/*----------------------------------------------------------------------------------------
      Observe que você não está preso ao velho conceito de impressão em uma só direção.
      Ou seja, você pode imprimir aleatoriamente em qualquer ponto da página.   Isto 
      porque a página é "montada" integralmente antes do início da impressão.
      Veja que o comando seguinte imprime na parte inferior do retângulo.
*/
oPrinter:TextOutAt( nCol*nLarCar , nRow*nAltCar ,"Coluna: "+;
                  ALLTRIM(STR(oPrinter:Pcol()))+"- Linha: "+;
                  ALLTRIM(STR(oPrinter:Prow()))+"      -A linha seguinte vai aqui")
*
*-----------------------------------------------------------------------------------------
*     Este comando seguinte imprime na parte superior do retângulo.
*
oPrinter:TextOutAt(oPrinter:MM_TO_POSX(070), oPrinter:MM_TO_POSY(030), +;
                  "Imprimindo a 70mm da borda esquerda e 30mm da borda superior da " +;
                  "folha.") 
*
*
oPrinter:Box(       9970, 16970, 30020, 25020 )
oPrinter:FillRect( 10000, 17000, 30000, 25000, GREY )
*
oPrinter:TextOutAt(oPrinter:MM_TO_POSX(070), oPrinter:MM_TO_POSY(120), +;
                  "Imprimindo a 70mm da borda esquerda e 120mm da borda superior da " +;
                  "folha, no SEGUNDO BOX.") 
*
*
RETURN( NIL )

Imprimir Texto com fundo cinza

Enviado: 10 Jun 2012 10:35
por locio
Beleza.

Acabaram-se os meus problemas de impressão.

Ficou uma beleza

Muito obrigado Hasse

Lócio