Sending raw data to a labelprinter

P

peter.aghl

Hi

I need to send some raw data to a SATO printer
I can easily send the textstring to a laserprinter
But the SATO does nothing
I am almost sure that the textdata is correct (taken from another app
which works)

I have made a vb.net class based on this article
http://www.vbdotnetheaven.com/Code/Jun2003/2094.asp

I can ping the printers ip or use tracert
But I can access the printer if I try to add a networkprinter

I am a little puzzled :)

Thanks in advance

- Peter
 
P

Peter Lykkegaard

peter.aghl wrote
I need to send some raw data to a SATO printer
I am a little puzzled :)
The obvious: Send data via tcpip using port 9100

Something like this (found using Google)
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=126319&SiteID=1
http://discuss.develop.com/archives/wa.exe?A2=ind0406c&L=vbdotnet&D=0&T=0&P=4853

rgds/Peter

------------------------------------------------------
Try
Dim iLoop As Integer
Dim PrinterIP As Net.IPAddress

PrinterIP = Net.IPAddress.Parse("10.1.0.18")

Dim MyPrinter As New TcpClient(PrinterIP.AddressFamily)

MyPrinter.Connect(PrinterIP, 9100)
Dim stream As NetworkStream = MyPrinter.GetStream()
Dim data As [Byte]()

For iLoop = 1 To CType(Me.txtQuantity.Text, Integer)
data = System.Text.Encoding.ASCII.GetBytes("^XA")
stream.Write(data, 0, data.Length)
data = System.Text.Encoding.ASCII.GetBytes("^LH30,30")
stream.Write(data, 0, data.Length)
data = System.Text.Encoding.ASCII.GetBytes( _
"^FO20,10^AD^FD" & Me.lblPOSDesc.Text & "^FS")
stream.Write(data, 0, data.Length)
data = System.Text.Encoding.ASCII.GetBytes( _
"^FO20,60^B3^" & Me.txtUPC.Text & "^FS")
stream.Write(data, 0, data.Length)
data = System.Text.Encoding.ASCII.GetBytes("^XZ")
stream.Write(data, 0, data.Length)
Next
MyPrinter.Close()

Catch Ex As System.Exception

Dim sMsg As String = "Error Printing New Label : " & Ex.Message
MessageBox.Show( _
sMsg, "Error Printing New Label ", _
MessageBoxButtons.OK, _
MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1)
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top