我需要使用 C# 在斑马标签打印机上打印标签和条形码。我以前从未使用过它们,但阅读并试图找出一种方法来做到这一点。我从http://support.microsoft.com/kb/322091遇到了这段代码,但它没有用。从我的试验中,我可以看到我能够将数据发送到打印机,但它没有响应和打印。我正在使用按钮将命令发送到打印机,就像在 kb 文章中一样。
private void ConnectButton_Click(object sender, EventArgs e)
{
// Allow the user to select a printer.
string s = "B26,26,0,UA0,2,2,152,B,\"{0}\"";
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
// Send a printer-specific to the printer.
RawPrintrHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName,s);
MessageBox.Show("Data sent to printer.");
}
}