是否可以使用 .NET POS 垂直打印条形码

本文关键字:垂直 打印 条形码 POS NET 可以使 是否 | 更新日期: 2023-09-27 18:33:08

请帮助我。我是c# POS .net打印的新手,我正在使用EPSON TM-T81热敏打印机进行我的项目。

我已经知道如何使用PosPrinter.PrintBarcode方法水平打印条形码,但我的问题是我想垂直打印条形码。

我可以使用 PosPrinter.RotatePrint 方法垂直打印任何文本,前提是我将其 PrintRotate 指定为以下任何枚举:左90,正常,钻机90,旋转180,条形码,位图

我注意到PrintRotaion同时包含条形码和位图,所以我认为我也可以使用PosPrinter.RotatePrint垂直打印条形码,我这样做了:

//the PosPrinter obj is named printer and has already been opened,claimed and enabled
printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Barcode);
printer.PrintBarCode(PrinterStation.Receipt,"123",BarCodeSymbology.Code128,printer.RecLineHeight,printer.RecLineWidth,PosPrinter.PrinterBarCodeCenter,BarCodeTextPosition.Below);
//stop rotation and back to normal printing
printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Normal);

这段代码可以完美编译,但是当我开始执行代码时,将处理异常,因为我在此块中使用了try-catch。

这是例外:

方法 RotatePrint 引发异常。 尝试对设备执行非法或不受支持的操作,或者使用了无效的参数值。

我阅读了PrintRotate.Barcode的描述,它说:

旋转条形码打印。(使用上述旋转值之一进行 OR。

现在,"(使用上述旋转值之一进行ORed("是什么意思?我是否必须在这样的代码块之前指定另一个 PrintRotation 枚举?

PosPrinter obj 被命名为打印机,并且已被打开、声明和启用

//I added this
printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Left90);
printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Barcode);
printer.PrintBarCode(PrinterStation.Receipt, "123", BarCodeSymbology.Code128, printer.RecLineHeight,printer.RecLineWidth,PosPrinter.PrinterBarCodeCenter,BarCodeTextPosition.Below);
printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Normal);

当我尝试执行这些语句时,我仍然得到相同的异常。

请帮助我。条形码可以垂直打印吗?这不是垂直打印条形码的方法吗?非常感谢你们。

是否可以使用 .NET POS 垂直打印条形码

"(使用上述旋转值之一进行 OR。表示使用按位 OR 运算符连接两个枚举值。

printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Barcode | PrintRotation.Left90);

这对我有用。

在尝试旋转之前检查可用的旋转,因为它可能不受支持。在我使用星形打印机tsp100的情况下,仅支持"正常"和"旋转180"。

var rotationList = m_Printer.RecBarCodeRotationList;