bom dia, Galera ...
estou meio desatualizado ... e gostaria de saber se já existe algo para imprimir em impressora usb diretamente, como fazÃamos nas impressoras epson matriciais porta LPT1 ....
Abraço,

Moderador: Moderadores
Realmente bem desatualizado.... Isso existe desde que o xHarbour existe.deividdjs escreveu:estou meio desatualizado ... e gostaria de saber se já existe algo para imprimir em impressora usb diretamente
/*
compilar usando: Hbmk2 exemplo.prg -lhbwin -lxhb
*/
Function Main()
Local cPrinter
Local cTexto := "Teste de impressão" + Hb_EOL()
MemoWrit( "ArqPrin.Txt", cTexto )
// cPrinter := GetDefaultPrinter() // pega impressora padrão, ou
cPrinter := MyPrinters() // seleciona a impressora...
If !Empty( cPrinter )
PrintFileRaw( cPrinter, "ArqPrin.Txt", "Impressao Teste" ) // imprime
EndIf
Return Nil
Func MyPrinters()
Local i, nPrn, oPrn, nMaxLen := 0, aPNomes := {}
Local aPrn := GetPrinters()
If Empty( aPrn )
Alert( "Nenhuma impressora Instalada" )
Return Nil
Endif
For i=1 To Len( aPrn )
AaDd( aPNomes , aPrn[i,1] )
nMaxLen := If( Len( aPrn[i,1] ) > nMaxLen, Len( aPrn[i,1] ), nMaxLen )
Next
Clear Screen
nPrn := AChoice( 5, 10, Len( aPrn )+5, nMaxLen+1, aPNomes, .T., Nil , aPNomes )
If nPrn = 0
Return Nil
Endi
Clear Screen
cPrinter := AllTrim( aPNomes[nPrn] )
Return cPrinter
cPorta := PrnGetPort()
cPrinter := PrinterPortToName( cPorta )
if empty( cPrinter )
cPrinter := PrinterPortToName( "USB002" )
if empty(cPrinter)
cPrinter := PrinterPortToName( "USB001" )
endif
endif
// Grave o arquivo...
PrintFileRaw( cPrinter, TrueName("MINUTA.TXT"), "Impressão de Vendas" )
até hoje não consegui imprimir ...
if Imp_PORTA == 2 && USB/REDE
RSTENV(REIMPRI)
c_codped := cc_codped
IMP_PEDVEN() // imprime em arquivo .PRN
IMPRIMI_RAW(REL_TELA)
endif
tmp := "tm" + substr(time(),4,2) + substr(time(),7,2) + "pv" && impressao de pedido de venda
do while .t.
if imp_pedven = 1 .and. imp_PORTA = 1
if .not. CHKPRN()
set filter to
tmp->(dbclosearea())
tmp += ".dbf"
ferase (tmp)
cdx += ".cdx"
ferase (cdx)
return(2)
endif
endif
SETCURSOR(0)
set color to "N/W*"
IMP := WIN(12,25,17,51, "Aguarde!", WT_AZUL2BRANCO, WD_AZUL2BRANCO)
@14,29 say "I M P R I M I N D O" color "R/W*"
@15,26 say "----------------------------------"
@16,31 say "Copia de Nº"
@16,43 say copia picture "9" color "R/W*"
inkey(1)
if imp_pedven = 1 .and. imp_PORTA = 1 && LPT1
set printer to LPT1
set device to printer
set printer on
endif
public REL_TELA := TMP
if imp_pedven = 2 .or. imp_porta = 2 // USB
set printer to (tmp) + ".prn"
set device to printer
set printer on
set console off
endif
set color to
vcab = .t.
n_item := 1
vez := 1
n_valserv := 0
n_valprod := 0
*-------------------------------*
function IMPRIMI_RAW(p_arquivo) // IMPRIMI IMPRESSORA MATRICIAL MODO DRAFT
*-------------------------------*
local TELA_ANT
save screen to TELA_ANT
ARQ_TXT := (p_arquivo) + ".PRN"
cPrint:= GetDefaultPrinter() // pega impressora padrÆo
PrintFileRaw(cPrint,ARQ_TXT)
fclose(ARQ_TXT)
erase (p_arquivo) + ".PRN"
restore screen from TELA_ANT
setcursor(3)
return(0))
porem ele sai tudo DRAFT NORMAL
Usuários vendo este fórum: Google [Bot] e 7 visitantes