Printing to an IP adress

Printing to an IP adress

Postby Jack » Fri Sep 21, 2012 12:51 pm

Hello,
I use this code to send character to a THERMAL PRINTER (Zebra ZPL) connected to LPT port

How to to if it is a network printer ?

nfp := fcreate("LPT1")
*
ww:="^XA" && tjs
fwrite(nfp,ww+CRLF)
ww:="^MD25" && temperature 0 a 30
fwrite(nfp,ww+CRLF)
ww:="^LH05,50" && home position 0.5 cm
fwrite(nfp,ww+CRLF)
ww:="^XZ"
fwrite(nfp,ww+CRLF)
fclose(nfp)
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Printing to an IP adress

Postby cdmmaui » Fri Sep 21, 2012 1:02 pm

Hi Jack,

I am printing direct to Zebra and Intermec printers using the following code. The text in aLabel is the Intermec coding, you can change to Zebra's ZPL.


// Init...
nPort := 9100
cIPAddr := "192.168.1.125"
aLabel := {}
cDat := ""

// Init...
AADD( aLabel, 'CLL' )
AADD( aLabel, 'FONT "Swiss 721 BT",20' )
AADD( aLabel, 'DIR 1' )
AADD( aLabel, 'ALIGN 5' )
AADD( aLabel, 'PRPOS 400,925' )
AADD( aLabel, 'PRTXT "ABC COMPANY' )
AADD( aLabel, 'FONT "Swiss 721 BT",32' )
AADD( aLabel, 'ALIGN 5' )
AADD( aLabel, 'PRPOS 400,800' )
AADD( aLabel, 'PRTXT "' + cMrNo + '"' )
AADD( aLabel, 'FONT "Swiss 721 BT",14' )
AADD( aLabel, 'ALIGN 5' )
AADD( aLabel, 'PRPOS 400,700' )
AADD( aLabel, 'PRTXT "CUSTOMER: XYZ"' )
AADD( aLabel, 'PRPOS 030,600' )
AADD( aLabel, 'FONT "Swiss 721 BT",14' )
AADD( aLabel, 'ALIGN 1' )
AADD( aLabel, 'PRTXT "NO.: ' + cNo + '"' )
AADD( aLabel, 'PRPOS 460,600' )
AADD( aLabel, 'PRTXT "PKG NO: ' + LTRIM(STR(nStart,9)) + ' OF ' + LTRIM(STR(VAL(cPkg_rcv),9)) + '"' )
AADD( aLabel, 'PRPOS 030,525' )
AADD( aLabel, 'PRTXT "P.O. NO.: ' + cPo + '"' )
AADD( aLabel, 'PRPOS 460,525' )
AADD( aLabel, 'PRTXT "PKG TYPE: ' + cPkg + '"' )
AADD( aLabel, 'PRPOS 030,450' )
AADD( aLabel, 'PRTXT "LBS: ' + LTRIM(TRANSF(nLbs,"999,999.99")) + '"' )
AADD( aLabel, 'PRPOS 030,375' )
AADD( aLabel, 'PRTXT "DIMS: ' + cDims + '"' )
AADD( aLabel, 'PRPOS 030,300' )
AADD( aLabel, 'PRTXT "DATE RECEIVED: ' + DTOC( dRecv ) + '"' )
AADD( aLabel, 'PRPOS 030,225' )
AADD( aLabel, 'PRTXT "PIECE NO: ' + LTRIM(STR(nPcno,9)) + '"' )
AADD( aLabel, 'PRPOS 400,110' )
AADD( aLabel, 'DIR 1' )
AADD( aLabel, 'ALIGN 2' )
AADD( aLabel, 'BARTYPE "CODE128"' )
AADD( aLabel, 'PRBAR "' + cBarcode + '"' )
AADD( aLabel, 'PRINTFEED' )

FOR nX1=1 TO LEN(aLabel)
cDat += aLabel[nX1] + CRLF
NEXT nX1
FWRITE( hHan, cDat )
SENDDATA( nPort, cIPAddr, cDat )

RETURN (.T.)

//-----------------------------------------------------------------------------
STATIC FUNCTION SENDDATA( nPort, cIP, cMsg )

LOCAL oSocket := TSocket():New( nPort )

oSocket:bConnect := { || oSocket:SendData( "MSG " + cMsg ),;
oSocket:End() }

oSocket:Connect( cIP )

RETURN NIL
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Printing to an IP adress

Postby Jack » Fri Sep 21, 2012 2:40 pm

Thanks,

It works with my network printer .
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Printing to an IP adress

Postby Jack » Thu Sep 27, 2012 4:13 pm

Is it the same if the printer is connect to a print server ??
I replace the IP with the print server name ?
Thanks .
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Printing to an IP adress

Postby MarcoBoschi » Sun Sep 30, 2012 4:21 pm

I am also interested in this answer
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 106 guests