1

I am trying to print a label from my Nativescript+Vue application for IOS. I can successfully connect to printer, however when I try to print an image, it will give me an Error. The printer I am using is the "QL-810W". The label that I have loaded is the 62mm roll (no set length) and can support both red and black.

Here is the surrounding code:

exports.BrotherPrinterClass = BrotherPrinterClass;

var BrotherPrinter = (function () {
    function BrotherPrinter() {
    }

    BrotherPrinter.prototype.print_image = function (PrinterName, ipAddress, image) {

        try {
            let printer = new BRPtouchPrinter()
            printer.printerName = PrinterName
            printer.interface = CONNECTION_TYPE_WLAN
            printer.setIPAddress(ipAddress)

            let settings = new BRPtouchPrintInfo()
            settings.strPaperName = "62mmRB"
            settings.nPrintMode = 0x03 //PRINT_FIT_TO_PAGE
            settings.nAutoCutFlag = 0x00000001 //OPTION_AUTOCUT
            settings.nOrientation = 0x00 //ORI_LANDSCAPE
            settings.nHorizontalAlign = 0x01 //ALIGN_CENTER
            settings.nVerticalAlign = 0x01 //ALIGN_MIDDLE
            printer.setPrintInfo(settings)

            if (printer.startCommunication()) {
                //Print to the printer
                let errorCode = printer.printImageCopy(image.ios.CGImage, 1);
                if (errorCode != 0)
                    console.log("ERROR - ", errorCode)
                }
                printer.endCommunication()
            }
            else{
                console.log("Failed to connect")
            }   
        }
        catch(e) {
            console.log("Error - ", e);
        }
    };

This then returns the error "-41" which correlates to ERROR_WRONG_LABEL_. I've tried adjusting all properties, I've also tried settings.strPaperName = "62mm" and that didn't return anything different.

The image that is been passed in is of an ImageSource type, and I've also tried the following line, let errorCode = printer.printImageCopy(image.ios, 1);. This returns an error code of 0 which correlates to ERROR_NONE_ But nothing gets printed out. And as far as I know, this isn't a CGImage like the SDK wants.

I can print from an iPad using the "iPrint&Label" app. Just not from the SDK

EDIT: I have tried to print from a file using printFilesCopy(). This returns no error when I go to print, but nothing gets printed. Additionally, I can set the settings incorrectly (eg, change '62mmRB' for '102mm') or I can outright not set the settings by commenting out the printer.setPrintInfo(settings) line. These changes do not impact the result.

Furthermore, I have purchased a 62mm black only roll, and tried that, only to find that I have the exact same issue.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
matty0005
  • 26
  • 3
  • I see the vendor provides a sample application along with SDK. Did you try running the sample app, still seeing same issue while printing an image? – Manoj Nov 15 '19 at 18:06
  • Hi, thanks for the response. Yes, i was able to run the sample app, and it seemed to print fine. – matty0005 Nov 16 '19 at 03:43
  • Then you must be missing something. Try to compare the code, do you have link to their sample project? – Manoj Nov 16 '19 at 04:16
  • Hey, I have a link to their sample project, though it is done in Objective-C and not nativescript. [link](https://www.brother.co.jp/eng/dev/mobilesdk/download/index.aspx) and i am using version 3.1.12. Ive had a quick look and play with the app, but i do not know much about objective-c – matty0005 Nov 16 '19 at 04:58
  • I know very well it's objective c, you should refer the NativeScript marshalling docs to understand the JS translation here. I will take a look as soon I find some time. – Manoj Nov 16 '19 at 05:00
  • Did you have any luck implementing this sdk to nativescript? – Trevize Daneel Mar 24 '23 at 08:04

0 Answers0