我正在尝试在爱普生TM-T20II上打印图像。下面是我的代码:
string path = @"test.bmp";
if (File.Exists(path))
{
Console.WriteLine("exists");
OPOSHelper.printer.ErrorEvent += Printer_ErrorEvent; // Do I have to configure this?
OPOSHelper.printer.SetBitmap(1, PrinterStation.Receipt, path, PosPrinter.PrinterBitmapAsIs, PosPrinter.PrinterBitmapCenter);
OPOSHelper.printer.PrintNormal(PrinterStation.Receipt, "\x1B|1B");
}
else
{
Console.WriteLine("DOES NOT EXIST!!!");
}当我运行它时,我得到了下一个错误:
方法SetBitmap引发异常。出现了特定于类的错误条件。错误条件代码位于ResultCodeExtended属性中
我想要读取ResultCodeExtended property,但我找不到方法,我必须配置ErrorEvent吗?或者它是如何支持阅读的?
发布于 2018-07-21 09:02:27
您的OPOSHelper.printer可能是由某人创建的库,您将通过该库使用内部ControlObject。
如果OPOSHelper.printer不公开ResultCodeExtended,您就不能知道它。
请查看OPOSHelper.printer规范,或对应的源码。
发布于 2018-08-17 22:09:24
将代码包装在try/catch中。SetBitmap函数是.NET框架的POS机的一部分。
要查看有关SetBitmap函数的文档,请参阅此链接:https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms843078(v%3dwinembedded.11)
您的try catch应该将异常类型转换为至少一个POSControlException:
SetBitmap可能会抛出具有以下ErrorCodes的PosControlException:
Illegal发生以下情况之一:
指定的站点无效-它必须是Slip或Receipt。
指定的工作站不支持位图打印(即,相应的CapSlpBitmap或CapRecBitmap属性设置为false)。
打印机当前处于插入模式。打印机当前处于移除模式。为bitmapNumber指定的数字小于1或大于20,因此无效。
width的值小于或等于零,但未设置为PrinterBitmapAsIs,因此无效。
NoExist找不到
fileName。
ExtendedExtendedErrorTooBig:位图太宽而无法在不进行转换的情况下打印,或者太大而无法转换。
ExtendedErrorBadFormat:指定的文件不是位图文件,或者其格式不受支持。
如果您在捕获时设置了断点,您肯定会看到有关ResultCodeExtended属性的详细信息。
https://stackoverflow.com/questions/51450218
复制相似问题