Is it possible to print barcodes vertically using POS for .NET?

1.6k Views Asked by At

please help me. I am new to c# POS .net printing and I am using an EPSON TM-T81 thermal printer for my project.

I already know how to print barcodes horizontally using the PosPrinter.PrintBarBarcode method but my problem is I want to print the barcode vertically.

I can print vertically any text using PosPrinter.RotatePrint method provided that i specify its PrintRotation to any of the following enums: Left90,Normal,Rigth90,Rotate180,Barcode,Bitmap

I noticed that the PrintRotaion contains both Barcode and Bitmap so I thought that I can also print barcode vertically using the PosPrinter.RotatePrint and i did this:

//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);

This code will perfectly compile but when i start to execute the code, an exception will be handled as I have used try-catch in this block.

This is the Exception:

Method RotatePrint threw an exception. Attempt was made to perform an illegal or unsupported operation with the device, or an invalid parameter value was used.

I read the PrintRotation.Barcode description and it says:

Rotate barcode printing. (ORed with one of the above rotation values.)

Now, what does the "(ORed with one of the above rotation values.)" mean? Do I have to specify another PrintRotation enum before my block of code like this?

the PosPrinter obj is named printer and has already been opened,claimed and enabled

//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);

When i try to execute these statements i still get the same exception.

Please help me. Can barcode be printed vertically? Is this is not the way to print the barcode vertically? Thank you so much guys.

2

There are 2 best solutions below

0
On

"(ORed with one of the above rotation values.)" Means use the bitwise OR operator to join the two enum values.

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

This worked for me.

0
On

Check available rotation before attempting to rotate since it may not be supported. In my case with Star Printer tsp100, only 'Normal' and 'Rotate180' is supported.

var rotationList = m_Printer.RecBarCodeRotationList;