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

时间:2014-12-05 04:50:09

标签: c# .net printing barcode-printing

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

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

我可以使用PosPrinter.RotatePrint方法垂直打印任何文本,前提是我将PrintRotation指定给以下任何枚举: Left90,正常,Rigth90,Rotate180,条码,位图

我注意到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抛出异常。尝试对设备执行非法或不受支持的操作,或者使用了无效的参数值。

我阅读了PrintRotation.Barcode描述并说:

  

旋转条形码打印。 (与上述旋转值之一进行“或”运算。)

现在,"(与上述旋转值之一进行OR运算。)"意思? 我必须在我的代码块之前指定另一个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);

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

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

2 个答案:

答案 0 :(得分:0)

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

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

这对我有用。

答案 1 :(得分:0)

在尝试旋转之前检查可用的旋转,因为它可能不受支持。在我使用Star Printer tsp100的情况下,只有' Normal'和' Rotate180'得到支持。

var rotationList = m_Printer.RecBarCodeRotationList;
相关问题