Olá!
Coloque seu código por favor.
Só a parte que imprime.
Saudações,
Itamar M. Lins Jr.

Moderador: Moderadores
#require "hbwin"
PROCEDURE Main()
LOCAL nPrn := 1
LOCAL cFileName := Space( 40 )
LOCAL GetList := {}
LOCAL aPrn := win_printerList()
CLS
IF Empty( aPrn )
Alert( "No printers installed - Cannot continue" )
ELSE
DO WHILE nPrn != 0
CLS
@ 0, 0 SAY "win_PrintFileRaw() test program. Choose a printer to test"
@ 1, 0 SAY "File name:" GET cFileName 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 ], cFileName )
ENDIF
ENDDO
ENDIF
RETURN
STATIC PROCEDURE PrnTest( cPrinter, cFileName )
LOCAL lDelete
IF Empty( cFileName )
hb_MemoWrit( cFileName := hb_FNameExtSet( __FILE__, ".prn" ), "Hello World!" + Chr( 12 ) )
lDelete := .T.
ELSE
lDelete := .F.
ENDIF
Alert( "win_PrintFileRaw() returned: " + hb_ntos( win_PrintFileRaw( cPrinter, cFileName, "testing raw printing" ) ) )
IF lDelete
FErase( cFileName )
ENDIF
RETURN
Function Main()
LOCAL cImpPadrao := GetDefaultPrinter()
SetMode(25,80)
cArq = "ARQIMP"
*
Imprime(cArq, cImpPadrao, "TESTANDO IMPRESSAO")
return nil
*----------------------------------*
Function Imprime(cArq,cPrint,cTit)
*----------------------------------*
Local oPrn, aPrn:=WIN_PRINTERLIST()
hb_default(@cPrint,win_PrinterGetDefault())
hb_default(@cTit,"PEDIDO")
If Empty(cArq)
alert('Informe algo p/ imprimir.')
Return .F.
EndIf
*
If empty(aPrn)
alert('Informe algo p/ imprimir.')
Return .F.
EndIf
*
Wait cArq
Wait cPrint
Wait cTit
*
nRet := Win_PrintFileRaw(cPrint,cArq,cTit)
if nRet < 1
cMsg := 'Erro Imprimindo: '
SWITCH nRet
CASE -1
cMsg += "Parâmetro inválido passado" ; EXIT
CASE -2
cMsg += "WinAPI OpenPrinter() Falha na chamada" ; EXIT
CASE -3
cMsg += "WinAPI StartDocPrinter() Falha na chamada" ; EXIT
CASE -4
cMsg += "WinAPI StartPagePrinter() Falha na chamada" ; EXIT
CASE -5
cMsg += "WinAPI malloc() of memory failed" ; EXIT
CASE -6
cMsg += "Arquivo " + cArq + " não Localizado" ; EXIT
//DEFAULT
// cMsg += cFile + " PRINTED OK!!!"
END
*
*hwg_Msgstop(cMsg)
alert(cMsg)
EndIf
*
Wait str(nRet)
Return .T.
Vc está entendendo a proposta de solução do seu problema, ou quer que apenas o Jairo responda ?
Olá Moises, você pode tentar mudar a configuração da impressora. Vá em Dispositivos e Impressoras, clique com o botão direito sobre o Ãcone da Laserjet 1005, selecione Propriedades e na janela que aparecer vá na aba Avançado. Na opção procure pelo botão Processador de Impressão e clique, mude para WinPrint e escolha o formato RAW. Então salve as alterações e reinicie o computador para elas entrarem em vigor. Esta dica é dada pelos profissionais da HP ultimamente aqui no Fórum. Boa sorte!
*********************************
Function PrintWinPrn(cArq,cPrint)
*********************************
*
*
Local oPrn, aPrn:=WIN_PRINTERLIST(), n := 0
if empty(aPrn)
hwg_Msginfo('Não há impressoras instaladas')
return .f.
endif
If cPrint == Nil
cPrint := win_PrinterGetDefault()
EndIf
oPrn := win_prn():New(cPrint)
oPrn : LandScape := .F.
oPrn : FormType := WIN_DMPAPER_A4
oPrn : Copies := 1
oPrn : CharSet(255)
//oPrn : setfont('Courier New',,10,{ 4, -70 },,,255)
oPrn : SetFont( "Lucida Console", 8, { 4, -70 } )
If !oPrn:Create()
hwg_Msginfo("Não foi criado documento")
Return Nil
EndIf
If !oPrn:startDoc("Imprimindo Documento")
hwg_Msginfo("Erro na Impressora")
Return Nil
EndIf
HB_CDPSelect("PT850")
cText := memoread(cArq)
nLinh := mlcount(cText)
oPrn:NewLine()
oPrn:NewLine()
For n := 1 to nLinh
oPrn:Textout(WIN_ansitooem(memoline(cText,,n)),.t.)
Next
oPrn:EndDoc()
HB_CDPSelect( "PTISO")
Return .t.
Usuários vendo este fórum: Nenhum usuário registrado online e 8 visitantes