如何在C#POS中为.Net垂直打印条形码 [英] How Do I print Barcode vertically in C# POS for .Net

查看:90
本文介绍了如何在C#POS中为.Net垂直打印条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



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



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



  //   PosPrinter obj被命名为打印机,已经打开,声明并启用 
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);



这段代码将完美编译,但是当我开始执行代码时,将处理

异常因为我在这个区块中使用了try-catch



这是例外:



方法RotatePrint投掷一个例外。尝试对设备执行非法或不受支持的操作,或者使用了无效的参数值。



我读了PrintRotation.Barcode描述,它说:



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



现在,(与上述旋转值之一进行OR运算。)是什么意思?我必须在我的代码块之前指定另一个PrintRotation枚举吗?



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

  //  我添加了 
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);





当我尝试执行这些语句时,我仍然得到同样的例外。



请帮帮我。条形码可以垂直打印吗?这不是垂直打印条形码

的方法吗?非常感谢你们。



[修改]代码格式[修改]

解决方案

检查可用的旋转之前尝试旋转,因为它可能不受支持。



 var rotationList = m_Printer.RecBarCodeRotationList; 


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.

[Modified] Code Format [Modified]

解决方案

Check available rotation before attempting to rotate since it may not be supported.

var rotationList = m_Printer.RecBarCodeRotationList;


这篇关于如何在C#POS中为.Net垂直打印条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆