4

Problem

I am trying to send zpl RAW to print server. There is a Zebra ZM400 printer. I could get PrintServer, PrintQueue objects. Also, I could add a job, and write to its JobStream.

I checked print queue (on Windows), and the document was sent. The printer data light blinks for 1/2 seconds.

Progress

Here is my code for print to print server:

PrintServer ps = new PrintServer(@"\\192.168.1.1");
PrintQueue pq = ps.GetPrintQueue("Printer 01");

Byte[] myByteBuffer = Encoding.ASCII.GetBytes(
    @"^XA^MMP^PW300^LS0^LT0^FT10,60^APN,30,30^FH\^FDSAMPLE TEXT^FS^XZ");

PrintSystemJobInfo psji = pq.AddJob();
psji.JobStream.Write(myByteBuffer, 0, myByteBuffer.Length);
psji.JobStream.Flush();
psji.JobStream.Close();

Issue

When I check print queue (on Windows), the document has 0 bytes. And then, the printer prints nothing.

Do I missing some special char? Or, do I send wrong raw data?

2 Answers 2

1

In my application I use the following code which works fine:

ZPLString = @"^XA^MMP^PW300^LS0^LT0^FT10,60^APN,30,30^FH\^FDSAMPLE TEXT^FS^XZ";
// Open connection
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
client.Connect("10.10.5.85", 9100);

// Write ZPL String to connection
System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream());
writer.Write(ZPLString);
writer.Flush();

// Close Connection
writer.Close();
client.Close();

edit: *port 6101 is the default for Zebra printers, 9100 is the alternate port

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

5 Comments

Thank you for your response. In your case, you are connecting directly to the printer. In my case, I need to connect through print server.
Ah, my bad. I see it now. ZPL looks okay btw. Although you could check if font P is available on the printer. (^APN,30,30)
I checked and font P is installed in Z:P.FNT. Anyway, when the font is not installed, letters are printed big and pixelated.
6101 is actually the default port, 9101 is the alternate port.
9100* apologies typo
0

Combining the OP's question and Johan's answer gives you a valid document using PrintServer:

LocalPrintServer localPrintServer = new LocalPrintServer();

// List the print server's queues
PrintQueue pq = localPrintServer.GetPrintQueue(@"Boca FGL 200 DPI");
PrintSystemJobInfo job = pq.AddJob();  
System.IO.StreamWriter writer = new System.IO.StreamWriter(job.JobStream);
writer.Write(@"hello world<p>");
writer.Flush();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.