C# 通过 LinePrinter API 将条码打印到 Intermec PB20

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-02 10:54:01  来源:igfitidea点击:

Print a barcode to a Intermec PB20 via the LinePrinter API

提问by Steve

Does anyone know how to print a barcode to the Intermec PB20 bluetooth printer from a Windows Compact Framework application? We are currently using the Intermec LinePrinter API but have been unable to find a way to print a barcode. ----------------------------------------------------

有谁知道如何从 Windows Compact Framework 应用程序将条码打印到 Intermec PB20 蓝牙打印机?我们目前正在使用 Intermec LinePrinter API,但一直无法找到打印条形码的方法。-------------------------------------------------- ——

采纳答案by Steve

Thank you all for your thoughts. Printing directly to the serial port is likely the most flexible method. In this case we didn't want to replicate all of the work that was already built into the Intermec dll for handling the port, printer errors, etc. We were able to get this working by sending the printer the appropriate codes to switch it into a different mode and then pass direct printer commands that way.

谢谢大家的想法。直接打印到串行端口可能是最灵活的方法。在这种情况下,我们不想复制已经内置到 Intermec dll 中的所有工作,用于处理端口、打印机错误等。我们能够通过向打印机发送适当的代码以将其切换到一种不同的模式,然后以这种方式直接传递打印机命令。

Here was our solution in case anyone else happens to encounter a similar issue working with Intermec Printers. The following code is a test case that doesn't catch printer errors and retry, etc. (See Intermec code examples.)

这是我们的解决方案,以防其他人在使用 Intermec 打印机时遇到类似问题。以下代码是一个测试用例,不会捕获打印机错误并重试等。(请参阅 Intermec 代码示例。)

Intermec.Print.LinePrinter lp;

int escapeCharacter = int.Parse("1b", NumberStyles.HexNumber);
char[] toEzPrintMode = new char[] { Convert.ToChar(num2), 'E', 'Z' };

lp = new Intermec.Print.LinePrinter("Printer_Config.XML", "PrinterPB20_40COL");
lp.Open();

lp.Write(charArray2); //switch to ez print mode

string testBarcode = "{PRINT:@75,10:PD417,YDIM 6,XDIM 2,COLUMNS 2, SECURITY 3|ABCDEFGHIJKL|}";
lp.Write(testBarcode);

lp.Write("{LP}"); //switch from ez print mode back to line printer mode

lp.NewLine();
lp.Write("Test"); //verify line printer mode is working

There is a technical document on Intermec's support site called the "Technical Manual" that describes the code for directly controlling the printer. The section about Easy Print describes how to print a variety of barcodes.

Intermec 的支持站点上有一份称为“技术手册”的技术文档,其中描述了直接控制打印机的代码。Easy Print 部分介绍了如何打印各种条码。

回答by Martin Marconcini

Last time I had to print Barcode (despite the printer or framework) I resorted to use a True Type font with the Barcode I needed. (In my case was EAN-13 something), an european barcode.

上次我不得不打印 Barcode(尽管有打印机或框架)时,我使用 True Type 字体和我需要的 Barcode。(在我的例子中是 EAN-13 的东西),一个欧洲条形码。

There are fonts where you simply write numbers (and/or letters when supported) and you get a perfect barcode any scanner can read :)

在某些字体中,您只需写下数字(和/或支持的字母),您就会获得任何扫描仪都可以读取的完美条形码:)

Google is your friend. I don't know if there are free ones.

谷歌是你的朋友。不知道有没有免费的

回答by Steve

Thank you for your answer. There are free fonts available -- However, the PB20 is a handheld printer with a few built-in fonts. It has the capability to print barcodes and can be manipulated directly via the serial port. Intermec provides a .Net CF API to make printing "easy", and it is using this API that we have been unable to figure out how to tell the printer to print a barcode.

谢谢您的回答。有可用的免费字体——但是,PB20 是带有一些内置字体的手持式打印机。它具有打印条码的能力,可以通过串口直接操作。Intermec 提供了一个 .Net CF API 来使打印变得“容易”,而正是使用这个 API,我们一直无法弄清楚如何告诉打印机打印条形码。

回答by Tim Williscroft

Ditch all API's and use a serial port API directly.

抛弃所有 API 并直接使用串行端口 API。

Talk the printers language and you can get decent results. Every other approach leads to frustration. Not so pretty, but that is the way my old factory worked. 4k print jobs per day, and none ever missed.

谈论打印机语言,您可以获得不错的结果。所有其他方法都会导致沮丧。不是很漂亮,但这就是我的旧工厂的工作方式。每天 4,000 份打印作业,没有遗漏。

回答by Frank Krueger

Free 3 of 9

免费 3 的 9

This is 3 of 9 (sometimes called "code 39"), a widely used barcode standard that includes capital letters, numbers, and several symbols. This is not the barcode for UPC's (universal price codes) found on products at the store. However, most kinds of barcode scanners will recognize 3 of 9 just fine.

这是 9 个中的 3 个(有时称为“代码 39”),这是一种广泛使用的条码标准,包括大写字母、数字和几个符号。这不是商店产品上的 UPC(通用价格代码)条形码。但是,大多数条码扫描器都能识别 9 个中的 3 个。