Boa tarde, da uma olhada nesse exemplo:
#include "FiveWin.ch"
#xcommand @ <nRow>,<nCol> SAY <cText> OF <oPrinter> => <oPrinter>:Say(<nRow>, <nCol>, <cText> )
function PPLA(wREF,wQTDE)
LOCAL nREF1:=SPACE(08), nREF2:=SPACE(07), nIND:=0
LOCAL nVEND:=0, nQTD:=0, nIX:="", nCob
LOCAL nLin := 0, nCol:=0
wREF:=SPACE(15)
wQTDE:=0
nREF1:=(wREF,8)
nREF2:=(wREF,7)
nVEND:=45.50
nQTD:=wQTDE
nCob:="00000017"
nIX:="R$"
oPrn:= TDosPrn():New("CODIGO.PRN")
oPrn:StartPage()
oPrn:lZeraBuffer:=.T. // Inibe o Pulo da P gina
WHIL ! ISPRINTER()
IF ! MsgRetryCancel( "Sua Impressora, Não Esta Ligada!!! " + CRLF + ;
"Favor Verificar e tente de novo!",;
"Erro de Impressora!" )
Return Nil
ENDIF
ENDDO
oPrn:Say(1, 1, CHR(002)+"m"+CHR(13) ) // * Configura em milimitros
oPrn:Say(1, 1, CHR(002)+"L"+CHR(13) ) // * INICIA com o comando de entrada do formato da etiqueta
oPrn:Say(1, 1, "H12"+CHR(13) ) // Qualidade
oPrn:Say(1, 1, "D11"+CHR(13) ) // Densidade
For nCol := 1 to 3
*If !Empty(aConteudo1[nVz,nCol])
cLin1 := "Produto"
cLin2 := "Texto2"
cLin3 := "20,60"
cBar := "0000000009173"
cBar1 := "5029"
// CHR(002)+"L"+CHR(13) = Comando de entrada do formato da etiqueta
// Formato Texto:
// 1.2.1.1.000.0100.0050, onde:
// 1 = Orientação da etiqueta
// 2 = Fonte (0-8 com Subtipo 000 /ou/ 9 com Subtipo de 000 a 007 /ou/ : com subtipo 000 a 005)
// 1 = Multiplicador Horizontal
// 1 = Multiplicador Vertical
// 000 = Subtipo da Fonte (000 a 007, depende da Fonte) - Quanto maior o número maior a fonte.
// 0100 = Posição inicial Y (linha) máximo=101.6
// 0050 = Posição inicial X (coluna) máximo=762
// Exemplo: = oPrn:Say(1,1,CHR(002)+"L"+CHR(13)+"121100001000050"+"Esta é uma etiqueta teste"+CHR(13)+"E"+CHR(13))
//
// Formato CodBar:
// 1.2.1.1.000.0100.0050, onde:
// 1 = Orientação da etiqueta
// 2 = Tipo da Barra EAN13, 2-5
// 1 = Largura da Barra Largua
// 1 = Largura da Barra Fina
// 000 = Altura do Código de Barras
// 0100 = Posição inicial Y (linha) máximo=101.6
// 0050 = Posição inicial X (coluna) máximo=762
/*
Do Case
Case nTipoBar=1 ; cLetra:="A" // Code 3 de 9
Case nTipoBar=2 ; cLetra:="E" // Code 128
Case nTipoBar=3 ; cLetra:="F" // Ean 13
Case nTipoBar=4 ; cLetra:="G" // Upca
End
*/
xcodi:="1F1209000100410"
if nCol=1
oPrn:Say(1, 1, "120100001700050"+cLin1+CHR(13) ) // nome da empresa
oPrn:Say(1, 1, "121100001500050"+cLin3+CHR(13) ) // valor
oPrn:Say(1, 1, "1F1209000100050"+cBar +CHR(13) ) // Código de Barras
//1F1203000500300
elseif nCol=2
oPrn:Say(1, 1, "120100001700410"+cLin1+CHR(13) ) // nome da empresa
oPrn:Say(1, 1, "121100001500410"+cLin3+CHR(13) ) // valor
oPrn:Say(1, 1, xcodi+cBar +CHR(13) ) // Código de Barras
elseif nCol=3
oPrn:Say(1, 1, "120100001700770"+cLin1+CHR(13) ) // nome da empresa
oPrn:Say(1, 1, "121100001500770"+cLin3+CHR(13) ) // valor
oPrn:Say(1, 1, "1A0009000100770"+cBar1+CHR(13) ) // Código de Barras
EndIf
Next nCol
oPrn:Say(1, 1, "E"+CHR(13) ) // * ENCERRA a etiqueta
oPrn:EndPage() // Obrigat¢rio
oPrn:End() // Idem
SysRefresh()
ImpSpool( "CODIGO.PRN", "LPT1", .T. )
return .t.
//----------------------------------------------------------------------------//
FUNCTION ImpSpool( cFileTxt, cPorta, lErase )
LOCAL CPRINTER
//para capturar antes da impressão
//cPorta := PrnGetPorta()
//WinExec( cPorta )
//depois da impressão
//WinExex( "Net Use Lpt1: \Delete" )
//Ficou mais facil e simples do que criar as portas na Classe TDosPrn
//cPorta := If( cPorta == nil, Alltrim( PrnGetPort() ), cPorta ) ; lErase := If( lErase == nil, .T., lErase );
//cPorta := PrnGetPort()
Default cPorta := Alltrim( PrnGetPort() ), lErase:= .t.
cPrinter := PrinterPortToName( cPorta )
IF EMPTY( cPrinter ) // By Kleyber Derick
cPrinter := PrinterPortToName( "USB002" )
IF EMPTY(cPrinter)
cPrinter := PrinterPortToName( "USB001" )
ENDIF
// e se estiver nas USB003 OU USB004?
ENDIF
IF .NOT. FILE( cFileTxt )
MsgInfo( OemToAnsi( "NÇO ACHEI O ARQUIVO MODO TEXTO PARA IMPRIMIR NA MATRICIAL" ), ;
OemToAnsi( "NÇO ACHEI O ARQUIVO MODO TEXTO PARA IMPRIMIR NA MATRICIAL" ) )
RETURN( .F. )
ENDIF
IF .NOT. EMPTY( cPrinter ) // TEM USB
PrintFileRaw( cPrinter, cFileTxt, "Impressão de CÓDIGO" )
ELSEIF LEN( cPorta ) <= 5 .and. Left( Upper(cPorta), 4 ) = "LPT1"
//--- Spool Local - Matricial em LPT1
cPorta:= "PRN"
WAITRUN("COMMAND.COM /C COPY /B " + cFileTxt + " " + cPorta, 0 )
ELSE
//--- Spool Remoto - Matricial em LPT1
WAITRUN("COMMAND.COM /C COPY /B " + cFileTxt + " " + cPorta, 0 )
ENDIF
IF lErase // Vem .T. da tela de vendas
FERASE( cFileTxt ) // apaga o .TXT
ENDIF
RETURN( .T. )