0

What is the best option to send text to the default printer?

The printer is a Zebra, and the text is a string of ZPL.

Many examples out there are with font size, graphics, points (x,y). Very confusing.

But I need to send the string and the printer does its work.

2 Answers 2

2

You can open the port directly using a p/invoke to OpenFile if you are connected using LPT or COM ports, but otherwise you will need to use the print ticket APIs to create a RAW formatted job. See http://support.microsoft.com/?kbid=322091 for a helper class which calls the appropriate platform functions to allows RAW print jobs from C#.

Sign up to request clarification or add additional context in comments.

1 Comment

I created a dll based on the RawPrinterHelper that you linked to link and have used it for projects where I need to send ZPL to a printer that might be USB, PAR or networked. It has worked really well.
2

Is your Zebra printer on a network?

If so, this will work-

// Printer IP Address and communication port string ipAddress = "10.3.14.42"; int port = 9100; // ZPL Command(s) string ZPLString = "^XA" + "^FO50,50" + "^A0N50,50" + "^FDHello, World!^FS" + "^XZ"; try { // Open connection using (System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient()) { client.Connect(ipAddress, port); // Write ZPL String to connection using (System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream())) { writer.Write(ZPLString); writer.Flush(); } } } catch (Exception ex) { // Catch Exception } 

I've used this library successfully as well for USB.

1 Comment

Did you try the library in my link above? I've used it for usb communication and it works quite well. ( z-bar.sourceforge.net )

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.