4

我需要使用 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.");
    }
}
4

1 回答 1

5

Nicholas Piasecki撰写的以下两篇博客文章对于尝试从 .NET 打印到 Zebra 打印机的每个人来说都是宝贵的资源:

他的网站现在似乎已经死了,所以链接会转到Wayback Machine

我使用 Zebra 打印机和 EPL 已有 10 多年了,其中大约 6 年使用 .NET。
当我开始使用 Zebra/EPL 和 .NET 时,我只需要这两篇博客文章就可以让它发挥作用。


关于这个:

我从http://support.microsoft.com/kb/322091遇到了这段代码,但它没有用。从我的试验中,我可以看到我能够将数据发送到打印机,但它没有响应和打印。

那篇文章的代码中有一个错误,解决方案在我链接的第一篇博客文章的底部进行了解释。

于 2015-08-27T20:38:09.760 回答