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?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Gustavo
  • 41
  • 1
  • 3

2 Answers2

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

Johan
  • 931
  • 9
  • 23
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();
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
smoore4
  • 4,520
  • 3
  • 36
  • 55