januslo / react-native-bluetooth-escpos-printer

React-Native plugin for the bluetooth ESC/POS & TSC printers.
MIT License
361 stars 420 forks source link

printLabel undefined is not a function #7

Closed shubhamdeol closed 5 years ago

shubhamdeol commented 5 years ago

When I am running BluetoothTscPrinter.printLable function. warning comes up with "undefined is not a function". I think you have implemented BluetoothTscPrinter package yet. all other commands are working as they are called with BluetoothEscposPrinter, for Example, this BluetoothEscposPrinter.printText("Hello world\n\r",{}); works completely fine.

januslo commented 5 years ago

TSC printer works fine. Emmm, what platform you are in, IOS or Android?

发自我的 iPhone

在 2018年12月17日,下午6:40,Shubham Choudhary notifications@github.com 写道:

When I am running BluetoothTscPrinter.printLable function. warning comes up with "undefined is not a function". I think you have implemented BluetoothTscPrinter package yet. all other commands are working as they are called with BluetoothEscposPrinter, for Example, this BluetoothEscposPrinter.printText("Hello world\n\r",{}); works completely fine.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

shubhamdeol commented 5 years ago

I am on android. I will share my code if you want

januslo commented 5 years ago

What Ran version you are working with?

发自我的 iPhone

在 2018年12月17日,下午11:44,Shubham Choudhary notifications@github.com 写道:

I am on android. I will share my code if you want

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shubhamdeol commented 5 years ago

I am testing on android version 8, and please add manual linking guides as well.

januslo commented 5 years ago

Emmm I wanna know the RN version . ESC manager works fine shows the problem not the link issue

发自我的 iPhone

在 2018年12月18日,下午6:05,Shubham Choudhary notifications@github.com 写道:

I am testing on android version 8, and please add manual linking guides as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shubhamdeol commented 5 years ago

Ohh sorry... I am using expo sdk 31, which is based on React Native 0.57. You have done amazing job by creating this package. It would be better if it can be easy to integrate. I don't know why I am facing so many problems.

On Tue 18 Dec, 2018, 5:04 PM janus j k lu <notifications@github.com wrote:

Emmm I wanna know the RN version . ESC manager works fine shows the problem not the link issue

发自我的 iPhone

在 2018年12月18日,下午6:05,Shubham Choudhary notifications@github.com 写道:

I am testing on android version 8, and please add manual linking guides as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/januslo/react-native-bluetooth-escpos-printer/issues/7#issuecomment-448190949, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1oYWJIohr1tvT4ywEfvxJYhJk6K5kRks5u6NLegaJpZM4ZWFwk .

shubhamdeol commented 5 years ago

image

see, here is the screenshoot of warning I am receiving with printLabel. and I am passing options as

initPrint = async () => {
    const options = {
        width: 40,
        height: 30,
        gap: 20,
        direction: BluetoothTscPrinter.DIRECTION.FORWARD,
        reference: [0, 0],
        tear: BluetoothTscPrinter.TEAR.ON,
        sound: 0,
        text: [{
            text: 'I am a testing txt',
            x: 20,
            y: 0,
            fonttype: BluetoothTscPrinter.FONTTYPE.SIMPLIFIED_CHINESE,
            rotation: BluetoothTscPrinter.ROTATION.ROTATION_0,
            xscal:BluetoothTscPrinter.FONTMUL.MUL_1,
            yscal: BluetoothTscPrinter.FONTMUL.MUL_1
        },{
            text: '你在说什么呢?',
            x: 20,
            y: 50,
            fonttype: BluetoothTscPrinter.FONTTYPE.SIMPLIFIED_CHINESE,
            rotation: BluetoothTscPrinter.ROTATION.ROTATION_0,
            xscal:BluetoothTscPrinter.FONTMUL.MUL_1,
            yscal: BluetoothTscPrinter.FONTMUL.MUL_1
        }],
        qrcode: [{x: 20, y: 96, level: BluetoothTscPrinter.EEC.LEVEL_L, width: 3, rotation: BluetoothTscPrinter.ROTATION.ROTATION_0, code: 'show me the money'}],
        barcode: [{x: 120, y:96, type: BluetoothTscPrinter.BARCODETYPE.CODE128, height: 40, readable: 1, rotation: BluetoothTscPrinter.ROTATION.ROTATION_0, code: '1234567890'}],
        // image: [{x: 160, y: 160, mode: BluetoothTscPrinter.BITMAP_MODE.OVERWRITE,width: 60,image: base64Image}]
     }

BluetoothTscPrinter.printLable(options)
    .then(()=>{
        //success
    },
    (err)=>{
        //error
    })
januslo commented 5 years ago

Sorry,never tested with expo.

januslo commented 5 years ago

you may need to do some alert/log in the index.js to figure out what is the problem. It's a good idea to start with the NativeModules after this line:

const {BluetoothManager,BluetoothEscposPrinter,BluetoothTscPrinter}= NativeModules;
shubhamdeol commented 5 years ago

Now package is integrated, other functions are running fine, but Bluetoothtcsprinter.printlabel not working. And I am not passing base 64 image. So image key is commented. But I want to use qr code and bar code

On Tue 18 Dec, 2018, 7:53 PM janus j k lu <notifications@github.com wrote:

Sorry,never tested with expo.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/januslo/react-native-bluetooth-escpos-printer/issues/7#issuecomment-448237186, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1oYarJMkrLMpx30arsNGMygL6i0oy_ks5u6PpagaJpZM4ZWFwk .

januslo commented 5 years ago

Here is a real case as a sample :

    await BluetoothTscPrinter.printLabel({
                        width: labelConfig.width,
                        height: labelConfig.height,
                        gap: labelConfig.gap,
                        direction: BluetoothTscPrinter.DIRECTION.FORWARD,
                        reference: [0, 0],
                        tear: BluetoothTscPrinter.TEAR.ON,
                        sound: 1,
                        text: texts,
                        barcode: barCode,
                        home:  0
                    });

No everything need for printing a label. further more , printLabel not printlabel

shubhamdeol commented 5 years ago

okay, so if I don't want image, and I want barcode only in that case it won't work ?

see, here I am getting this function, but properties like DIRECTION are not getting attached to object may be :(

image

shubhamdeol commented 5 years ago

hey tell me one more thing, if BluetoothEscposPrinter and BluetoothTscPrinter are different kind of printer. I have Escposprinter, so maybe it does not detect BluetoothTscPrinter