I have created an ActiveX control which contains all the methods to handle a printer (Star TSP100) such as instantiating, Opening printer etc. The ActiveX is being registered in the com. When i am using printers methods through javascript, all methods are working fine except PrintBarCode and PrintBitmap method and throwing an error.
For bitmap i have used :-
printer.PrintBitmap(PrinterStation.Receipt, path, percentWidth * lineWidth / 100, PosPrinter.PrinterBitmapCenter);
and for barcode :-
printer.PrintBarCode(PrinterStation.Receipt, code, BarCodeSymbology.Code93, 80, (int)(0.9 * lineWidth), PosPrinter.PrinterBarCodeCenter, BarCodeTextPosition.Below);
Although these two methods are also working in debug mode from visual studio. but after creating the setup and installing in the system it these two are not working.
The error is :-
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
I have the same problem and for the Bitmap I have a workaround:
Maybe the printer is not able to scale bitmaps. But for it's easy to scale your bitmap before sending it to the printer, I think this is a good workaround.
For the Barcode problem I can only say, that I had the wrong BarCodeSymbology (Ean13S instead of EanJan13). If I have further insights, I'll share them here.
dlg : is Open File Dialog
cbAlignment : is Combobox containing the three values : Left, Center, Right.
tbWidth and tbWidth : for the size of the printing
cbTextPosition : For the text position
Here is a Screen shot :
i have Epson-T20, code works fine for me :
And to print :
For the Codebar never tried it sorry, if i find something i will tell you, good luck guys.