Página 3 de 4

func getprinters() em harbour

Enviado: 03 Jul 2012 08:42
por ronnywdson
Maravilha

Obrigado pela velocidade e precisão que você teve ao responder minhas dúvidas.
O sucesso não vem por acaso.
Agora vejo porque esse fórum é tão bem conceituado entre nós "clippeiros" e agora "harbeiros".
Sucessos e obrigado

Att
Ronny Wdson

func getprinters() em harbour

Enviado: 04 Jul 2012 09:24
por ronnywdson
Toledo

Deu certo seguindo as suas orientações.
Só não está funcionando quando eu tento imprimir condensado usando: ? CHR(27)+"@"+CHR(27)+"C"+CHR(33)
Quando eu imprimia direto para a a LPT1 funcionava.
Agora que eu uso imprimir para um arquivo TXT e depois envia-la para a impressora padrão USB através da classe ou biblioteca HBWIN (não sei o nome certo), não funciona o condensado.
Tem alguma propriedade que eu tenho que mudar ou enviar outro caractere de compressão para o arquivo TXT?

Att
Ronny Wdson

func getprinters() em harbour

Enviado: 04 Jul 2012 13:43
por Imatech
Olá !

Imagino que esteja utilizando Win_Prn()

Código: Selecionar todos


              oPrinter:SetFont( 'Courrier New', 6.0, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

              oPrinter:SetFont( 'Courrier New', 6.5, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

              oPrinter:SetFont( 'Courrier New', 7.0, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

              oPrinter:SetFont( 'Courrier New', 7.5, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

              oPrinter:SetFont( 'Courrier New', 8.0, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

              oPrinter:SetFont( 'Courrier New', 9.0, 0 )  // Alternative Compressed print
              oPrinter:NewLine()
              oPrinter:TextOut( REPL( 'x', 40 ) )

Veja + exemplos em:

\Harbour\contrib\hbwin\tests

func getprinters() em harbour

Enviado: 04 Jul 2012 14:23
por Toledo
Ronny, só complementanto a informação que o Ronaldo passou na mensagem anterior:

Se você for imprimir o relatório todo condensado, então basta mudar o tamanho da fonte que é selecionada na função SetFont().

Código: Selecionar todos

oPrn :SetFont( "Courier New", 12, { 1, 17 }, 0, .F., .F. )
Como você vai usar a classe Win_prn(), então os comandos usados para condensar (CHR(27)+"@") e para determinar o tamanho do papel (CHR(27)+"C"+CHR(33)) não serão mais necessários e você pode retirá-los do arquivo TXT.

Abraços,

func getprinters() em harbour

Enviado: 04 Jul 2012 15:43
por ronnywdson
Boa tarde Ronaldo e Toledo

Utilizo a seguinte função para imprimir:

Código: Selecionar todos

Function PrintWinPrn(cArq,cPrint)
	Local oPrn, aPrn:=GetPrinters(), n := 0
	if empty(aPrn)
		MsgInfo('Não há impressoras instaladas')
		return .f.
	endif
	If cPrint == Nil
		cPrint := GetDefaultPrinter()
	EndIf
	 
	oPrn := win_prn():New(cPrint)
	oPrn :LandScape := .f.
	oPrn :FormType  := WIN_DMPAPER_USER 
	oPrn :PaperLength := 5.5*25.4*10 
	oPrn :PaperWidth := 8.5*25.4*10 
	oPrn :SetFont( "Courier New", 12, { 1, 17 }, 0, .F., .F. )
	oPrn :Copies  := 1
	oPrn:CharSet(255)

	if !oPrn:Create()
		MsgInfo("Não foi criado documento")
		return nil
	EndIf
	if !oPrn:startDoc("Imprimindo Documento")
		MsgInfo("Erro na Impressora")
		return nil
	EndIf

	HB_CDPSelect("PT850")
		setprc(5,0)
		cText := memoread(cArq) 
		nLinh := mlcount(cText)
		For n := 1 to nLinh
			oPrn:TextOut(HB_ANSITOOEM(memoline(cText,,n)),.t.)
		Next
		oPrn:EndDoc()
	HB_CDPSelect( "PTISO") 
 
Return .t.
Primeiro retirei todos os caracteres que determinam o tamanho tamanho do texto do meu TXT.
Depois segui a recomendação do Ronaldo e substitui SetFont() que eu estava usando pelo que ele falou, mas não deu certo. Continuou saindo do mesmo tamanho.
Depois mudei para a sugestão do Toledo e também não funcionou.
Será que há algo de errado com essa função?

Att
Ronny Wdson

func getprinters() em harbour

Enviado: 04 Jul 2012 15:54
por Toledo
Ronny, tenta então este:

Código: Selecionar todos

oPrn:SetFont("Courier New",13,{3,-50},0,.F.,.F.)
Abraços,

func getprinters() em harbour

Enviado: 04 Jul 2012 16:17
por ronnywdson
Toledo

Também não deu certo

func getprinters() em harbour

Enviado: 04 Jul 2012 16:54
por Toledo
Ronny, mude as linhas 20, 21, 22 e 23 do seu código de lugar, coloque logo depois da linha 11.

Obs.: evite também este espaço que fica entre o objeto oPrn e o : (dois pontos).

Abraços,

func getprinters() em harbour

Enviado: 04 Jul 2012 17:05
por Imatech
Exemplo baseado em \Harbour\HbWin\Samples...

Código: Selecionar todos


Function F_RM_PrintWinPrn( cArq, cPrint)
  LOCAL oPrn := ''
  LOCAL i, nCol, nRow
  Local n := 0
  Local cText := ''
  Local nLinh := 0

  If cPrint == Nil
   cPrint := GetDefaultPrinter()
  EndIf

  oPrn := Win_Prn():New( cPrint )

  IF !oPrn:Create()
    F_Sound()
    F_Win_Alert( "NAO FOI POSSIVEL GERAR A IMPRESSAO..." )
  ELSE
    IF !oPrn:startDoc( cPrint + '_' + cArq )
      F_Sound()
      F_Win_Alert( "FALHA AO GERAR A IMPRESSAO..." )
    ELSE
      oPrn:Landscape := .F.
      oPrn:FormType  := WIN_DMPAPER_USER
      oPrn:PaperLength := 5.5*25.4*10
      oPrn:PaperWidth := 8.5*25.4*10
      oPrn:SetFont( "Courier New", 6, {3,-62}, 0, .F., .F. )  // Alternative Compressed print
      oPrn:Copies := 1
      oPrn:CharSet(255)
      oPrn:SetPen( WIN_PS_SOLID, 1, HB_WIN_RGB_BLACK )
      oPrn:Bold(0)     // Normal
      oPrn:LineHeight := Int( oPrn:PixelsPerInchY / 8 )  // Default 6 lines per inch == # of pixels per line
      nCol := 11 * oPrn:CharWidth
      nRow := oPrn:LineHeight
      oPrn:Bold(0)
      oPrn:SetPos( nCol, nRow * 2 )

      FOR i := 1 TO 5
        oPrn:NewLine()
        oPrn:SetPos( nCol * 1.5  )
        oPrn:TextOut(oPrn:PrinterName+": MaxRow() = "+STR(oPrn:MaxRow(),4)+"   MaxCol() = "+STR(oPrn:MaxCol() - ( nCol * 4 ),4))
      NEXT

      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Linha Horizontal', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Line(  nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+5)
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Retangulo', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Box(   nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+200)
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Linha Horizontal', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Line(  nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+5)
      oPrn:NewLine()
      oPrn:Bold(800)

      FOR i := 1 TO 5
      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(oPrn:PrinterName+": MaxRow() = "+STR(oPrn:MaxRow(),4)+"   MaxCol() = "+STR(oPrn:MaxCol() - ( nCol * 4 ),4))
      NEXT

      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Linha Horizontal', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Line(  nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+5)
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Retangulo', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Box(   nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+200)
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:SetPos( nCol * 1.5 )
      oPrn:TextOut(Padr('Linha Horizontal', 132, '.') + '123456' )
      oPrn:NewLine()
      oPrn:Line(  nCol, oPrn:PosY+5, oPrn:PageWidth-INT( nCol/2 ), oPrn:PosY+5)
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:NewLine()
      oPrn:Bold(800)

*     HB_CDPSelect("PT850")

      cText := memoread(cArq)
      nLinh := mlcount(cText)
      For n := 1 to nLinh
        oPrn:SetPos( nCol * 1.5 )
        oPrn:NewLine()
        oPrn:TextOut(HB_ANSITOOEM(memoline(cText,,n)),.t.)
      Next

*     HB_CDPSelect("PTISO")

      oPrn:EndDoc()
    ENDIF
    oPrn:Destroy()
  ENDIF

Return( .T. )


func getprinters() em harbour

Enviado: 04 Jul 2012 17:38
por ronnywdson
Toledo

Fiz as alterações e coloquei o código oPrn:SetFont("Courier New",13,{3,-50},0,.F.,.F.) que você postou, mas a impressora fica imprimindo no mesmo lugar várias vezes. Ela repete a mesma letra várias vezes e o tamanho continua grande.

func getprinters() em harbour

Enviado: 04 Jul 2012 17:48
por Toledo
Ronny, se for possível, anexar aqui neste tópico o arquivo TXT do seu relatório.

Veja como anexar arquivos neste tópico:
https://pctoledo.org/forum/viewto ... =40&t=8000

Abraços,

func getprinters() em harbour

Enviado: 04 Jul 2012 18:22
por ronnywdson
Ronaldo

Usei a função que você enviou e deu certo a compressão.
Só que ficou pequeno demais, não ficou igual ao tamanho usado quando se imprime pelo DOS na LPT1.
E o espaçamento entre as linhas também ficou maior.
Será que é possível ficar do mesmo tamanho?


Toledo

func getprinters() em harbour

Enviado: 04 Jul 2012 18:45
por Imatech
Impressão Gráfica nunca ficará igual ao que você deseja... entretanto poderá buscar uma aproximação...

Experimente informar a fonte: "Draft" que é padrão nas impressoras matriciais...


Altura das linhas: Testar valores oPrn:LineHeight

Código: Selecionar todos


   oPrn:LineHeight := Int( oPrn:PixelsPerInchY /  8 ) 
   oPrn:LineHeight := Int( oPrn:PixelsPerInchY / 10 )
   oPrn:LineHeight := Int( oPrn:PixelsPerInchY / 12 )


Tamanhos alternados de fonte: oPrn:SetFont

Código: Selecionar todos


oPrn:SetFont( "Courier New", 6.5, 0 )
oPrn:SetFont( "Courier New", 7.0, 0 )
oPrn:SetFont( "Courier New", 7.5, 0 )
oPrn:SetFont( "Courier New", 8.0, 0 )
oPrn:SetFont( "Courier New", 8.5, 0 )
oPrn:SetFont( "Courier New", 9.0, 0 )

Exemplo para teste:

Código: Selecionar todos


Function F_RM_PrintWinPrn( cArq, cPrint)
 LOCAL oPrn := ''
 LOCAL i, nCol, nRow
 Local n := 0
 Local cText := ''
 Local nLinh := 0

 If cPrint == Nil
 cPrint := GetDefaultPrinter()
 EndIf

 oPrn := Win_Prn():New( cPrint )

 IF !oPrn:Create()
  F_Sound()
  F_Win_Alert( "NAO FOI POSSIVEL GERAR A IMPRESSAO..." )
 ELSE
  IF !oPrn:startDoc( cPrint + '_' + cArq )
   F_Sound()
   F_Win_Alert( "FALHA AO GERAR A IMPRESSAO..." )
  ELSE
   oPrn:Landscape := .F.
   oPrn:FormType := WIN_DMPAPER_USER
   oPrn:PaperLength := 5.5*25.4*10
   oPrn:PaperWidth := 8.5*25.4*10
   oPrn:SetFont( "Courier New", 6.5, 0 ) // Alternative Compressed print
   oPrn:Copies := 1
   oPrn:CharSet(255)
   oPrn:SetPen( WIN_PS_SOLID, 1, HB_WIN_RGB_BLACK )
   oPrn:Bold(0)  // Normal
   oPrn:LineHeight := Int( oPrn:PixelsPerInchY / 10 ) // Default 6 lines per inch == # of pixels per line
   nCol := 11 * oPrn:CharWidth
   nRow := oPrn:LineHeight
   oPrn:Bold(0)
   oPrn:SetPos( nCol, nRow * 2 )

   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": Courier New 6.5" )
   oPrn:NewLine()

   FOR i := 1 TO 5
    oPrn:NewLine()
    oPrn:SetPos( nCol * 1.5 )
    oPrn:TextOut(oPrn:PrinterName+": MaxRow() = "+STR(oPrn:MaxRow(),4)+" MaxCol() = "+STR( INT( oPrn:MaxCol() ),4) )
   NEXT
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()


   oPrn:SetFont( "Courier New", 7.0, 0 ) // Alternative Compressed print
   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": Courier New 7.0" )
   oPrn:NewLine()

   FOR i := 1 TO 5
   oPrn:NewLine()
   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": MaxRow() = "+STR(oPrn:MaxRow(),4)+" MaxCol() = "+STR( INT( oPrn:MaxCol()  ),4) )
   NEXT
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()

   oPrn:SetFont( "Courier New", 8.0, 0 ) // Alternative Compressed print
   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": Courier New 8.0" )
   oPrn:NewLine()

   FOR i := 1 TO 5
   oPrn:NewLine()
   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": MaxRow() = "+STR(oPrn:MaxRow(),4)+" MaxCol() = "+STR( INT( oPrn:MaxCol()  ),4) )
   NEXT

   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()
   oPrn:NewLine()

   oPrn:SetFont( "Arial", 7.0, 0 ) // Alternative Compressed print
   oPrn:SetPos( nCol * 1.5 )
   oPrn:TextOut(oPrn:PrinterName+": Arial 7.0" )
   oPrn:NewLine()

*  HB_CDPSelect("PT850")

   cText := memoread(cArq)
   nLinh := mlcount(cText)
   For n := 1 to nLinh
    oPrn:SetPos( nCol * 1.5 )
    oPrn:NewLine()
    oPrn:TextOut(HB_ANSITOOEM(memoline(cText,,n)))
   Next

*  HB_CDPSelect("PTISO")

   oPrn:EndDoc()
  ENDIF
  oPrn:Destroy()
 ENDIF

Return( .T. )


func getprinters() em harbour

Enviado: 04 Jul 2012 20:02
por ronnywdson
Ronaldo

Usei o código abaixo para imprimir em modo condensado:

Código: Selecionar todos

oPrn:SetFont( "Draft", 8.0, 0 ) 
E use esse outro para espaçar as linhas:

Código: Selecionar todos

oPrn:LineHeight := Int( oPrn:PixelsPerInchY /  10 )


Funcionou corretamente.
Valeu pela força

Att
Ronny Wdson

func getprinters() em harbour

Enviado: 04 Jul 2012 20:52
por Imatech
Olá Ronny !


As formas e classes disponiveis para impessão em Harbour são muito flexiveis e podem proporcionar resultados impressos muito elegantes...


Sobre o uso da fonte: Draft
Em impressoras não matriciais (as quais não possuem fonte Draft residente) o resultado impresso é bem diferente, pois ira utilizar outra fonte que não a definida...



Sucesso...