问题
我正在尝试将 zpl RAW 发送到打印服务器。有一台 Zebra ZM400 打印机。 我可以获得 PrintServer、PrintQueue 对象。此外,我可以添加一个作业,并写入其 JobStream。
我检查了打印队列(在 Windows 上),文档已发送。打印机数据指示灯闪烁 0/2 秒。
进展
这是我打印到打印服务器的代码:
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();
问题
当我检查打印队列(在 Windows 上)时,文档有 0 个字节。然后,打印机什么也不打印。
我是否遗漏了一些特殊字符?或者,我是否发送了错误的原始数据?
最佳答案
在我的应用程序中,我使用了以下运行良好的代码:
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();
编辑:*端口 6101 是 Zebra 打印机的默认端口,9100 是备用端口
关于c# - 无法通过 PrintServer 将原始 ZPL 发送到 Zebra 打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42415748/