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

问题描述:

请帮助我。我是c#POS .net打印新手,我正在为我的项目使用EPSON TM-T81热敏打印机。是否可以使用POS for .NET垂直打印条形码?

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

我可以垂直打印使用前提是我指定其PrintRotation以下任何枚举PosPrinter.RotatePrint方法的任何文本: 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描述和它说:

旋转条码打印。 (与上述其中一个旋转值进行或运算)。

现在,“(与上面的旋转值之一进行或运算)”是什么意思? 我是否必须在这样的代码块之前指定另一个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); 

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

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

“(与上述其中一个旋转值进行或运算)。”意思是使用按位或运算符来加入两个枚举值。

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

这对我有效。

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

var rotationList = m_Printer.RecBarCodeRotationList;