Printing to a network Thermal printer

burwelj

Member
Joined
Dec 11, 2007
Messages
5
Programming Experience
1-3
I am trying to printer to a Zebra LP 2844-Z printer using vb.net which is connected to our company's network.

I am able to print to a Zebra TLP 2844 which is connected via COM1.

here is the code for the local printer.


Dim port As SerialPort = New SerialPort("Com1", 9600, Parity.None, 8, StopBits.One)
port.Open()
Dim datamsg As String

datamsg = Chr(10) & "N" & Chr(10) & _
"B1,10,0,1A,5,6,200,N,""1K050013""" & Chr(10) & _
"A1,230,0,5,3,2,N,""050013""" & _
Chr(10) & "P" & Chr(10)

port.Write(datamsg, 0, datamsg.Length)
port.close()

I know the network printer uses ZPL Language as opposed to what i've shown as EPL. Where I'm lost is how do I send a printer command to a network printer?

thanks for the help!
 
Last edited:
Working code :-

VB.NET:
        Public Sub SendViaTCP(ByVal whatIP As String, ByVal whatPort As Integer, ByVal whatToSend As String)
            Dim tcpSender As TcpClient = New TcpClient()
            tcpSender.SendBufferSize = 4096
            tcpSender.Connect(whatIP, whatPort)
            If tcpSender.Connected = False Then
                MessageBox.Show("Not connected")
                tcpSender.Close()
                Exit Sub
            End If

            Dim nStream As NetworkStream = tcpSender.GetStream()
            If nStream.CanWrite = True Then
                Dim SendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes(whatToSend)
                nStream.Write(SendBytes, 0, SendBytes.Length)
                nStream.Flush()
            End If
            System.Threading.Thread.Sleep(500)

            nStream.Close()
            tcpSender.Close()
        End Sub
 
Back
Top