2014-12-05 67 views
0

請幫助我。我是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); 

當我嘗試執行這些語句我仍然得到同樣的異常。

請幫幫我。 條形碼可以垂直打印嗎? 這不是垂直打印條形碼的方式嗎? 非常感謝你們。

回答

0

「(與上述其中一個旋轉值進行或運算)。」意思是使用按位或運算符來加入兩個枚舉值。

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

這對我有效。

0

在嘗試旋轉之前檢查可用旋轉,因爲它可能不受支持。在我使用Star Printer tsp100的情況下,只支持「Normal」和「Rotate180」。

var rotationList = m_Printer.RecBarCodeRotationList;