我创建了一个 ActiveX 控件,其中包含处理打印机(Star TSP100)的所有方法,例如实例化、打开打印机等。ActiveX 正在 com.xml 中注册。当我通过 javascript 使用打印机方法时,所有方法都可以正常工作,除了 PrintBarCode 和 PrintBitmap 方法并引发错误。
对于我使用过的位图:-
printer.PrintBitmap(PrinterStation.Receipt, path, percentWidth * lineWidth / 100, PosPrinter.PrinterBitmapCenter);
对于条形码:-
printer.PrintBarCode(PrinterStation.Receipt, code, BarCodeSymbology.Code93, 80, (int)(0.9 * lineWidth), PosPrinter.PrinterBarCodeCenter, BarCodeTextPosition.Below);
虽然这两种方法也在 Visual Studio 的调试模式下工作。但是在创建设置并在系统中安装之后,这两个都不起作用。
错误是: -
Microsoft.PointOfService.PosControlException: Method PrintBarCode threw an exception. Attempt was made to perform an illegal or unsupported operation with the device, or an invalid parameter value was used.
at Microsoft.PointOfService.Legacy.LegacyProxy.ThrowLegacyMethodException(String methodName, Int32 ResultCode, Exception e)
at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethod(String methodName, Object[]& parameters, Boolean[] byRef)
at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethodAndCheckImpl(String methodName, Object[]& parameters, Boolean[] byRef)
at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethodAndCheckImpl(String methodName, Object[] parameters)
at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethodAndCheck(String methodName, Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7)
at Microsoft.PointOfService.Legacy.LegacyPosPrinter.PrintBarCode(PrinterStation station, String data, BarCodeSymbology symbology, Int32 height, Int32 width, Int32 alignment, BarCodeTextPosition textPosition)
at xyx.testclass.PrintBarCode(String code)
ErrorCode: Illegal
ErrorCodeExtended: 0