我需要使用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.");
}
}
Run Code Online (Sandbox Code Playgroud)