我尝试打印到斑马打印机。 斑马为我提供了一个标准的代码示例在C# 在那里,他们所使用的端口9100到每个i运行这段代码崩溃,因为没有这样的端口号提供 时间连接到打印机斑马打印机KR403端口号
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
client.Connect("127.0.0.1", 9100);
不过,我也用的telnet 127.0.01 9100,证实没有任何东西在收听9100 我也尝试过一些Zebra打印机使用的端口6101,但都没有成功。
我可以在DOS命令
print /D:\\127.0.0.1\KR403 d:\print.txt
这可以打印,并证明它侦听莫名其妙网络 内部运行。该设备是USB打印机,这使设置静态端口ID变得很复杂。也许还有一点奇怪,上面的命令确实打印了一个条形码,但并没有切断纸张;当我使用记事本打印(我认为它不使用网络打印),那么它剪纸,但纸张是40厘米长(方式大)..所以我在司机战斗它接缝。
我希望做的事情是使用C#发送打印命令并使用ZPL命令打印 微软也写了一篇关于原始打印的文章,但是在这台打印机上失败了。
我想要做的就是向本打印机发送ZPL指令。 ASLO试图通用TXT驱动程序,这个工程的记事本,但不是用C#
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// print /D:\\127.0.0.1\KR403 d:\print.txt
namespace PrinterTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Printer IP Address and communication port
string ipAddress = @"192.168.2.109";
int port = 6101; // 9100;//
// ZPL Command(s)
string ZPLString =
"^XA" +
"^FO50,50" +
"^A0N50,50" +
"^FDHello, World!^FS" +
"^XZ";
try
{
// Open connection
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
//client.Connect(ipAddress, port);
client.Connect(ipAddress, port);
// string tmp = "\\127.0.0.1\KR403";
// client.Connect(@"\\localhost",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();
}
catch (Exception ex)
{
MessageBox.Show("Error");
}
}
}
}
在你的机器上安装的打印机?打印机设置应显示控制面板中连接的端口。 – 2013-02-28 14:37:51
的确是这样,但它通常会读取端口nummber,我看到USB0001不是我可以使用。 – user613326 2013-02-28 18:25:42