{"_id":"@adelant/capacitor-label-printer","name":"@adelant/capacitor-label-printer","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.2":{"name":"@adelant/capacitor-label-printer","version":"0.0.2","description":"Provide a native interface to label printers","cordova":{"id":"capacitor-label-printer","platforms":["android","ios"]},"repository":{"type":"git","url":"git+https://github.com/adelantsoftware/capacitor-label-printer.git"},"keywords":["brother","print","sdk","label","ecosystem:cordova","cordova-ios","cordova-android"],"engines":{"cordova":">=3.6.0","cordova-android":">=6.0.0","android-sdk":">=26","apple-ios":">=10.0.0"},"author":{"name":"Diga Systems"},"bugs":{"url":"https://github.com/adelantsoftware/capacitor-label-printer/issues"},"license":"MIT","homepage":"https://github.com/adelantsoftware/capacitor-label-printer#readme","_id":"@adelant/capacitor-label-printer@0.0.2","gitHead":"bc3e96b56f31c3486f509eab98dfd085eda9774f","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-tA7Jy+TS11eB0d+iRfQ1N3Eh/viXGJnqW4FSc2fLBZKafSktbLvLS231qhkDhAm0zVdSW/WuoaUZDsnYlx+wQg==","shasum":"de79c84e69cb9f5207689c9a287401a242af8c4e","tarball":"https://registry.npmjs.org/@adelant/capacitor-label-printer/-/capacitor-label-printer-0.0.2.tgz","fileCount":158,"unpackedSize":58506610,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDemBWTC+1l2UGYxs0XwL2kJ/pqVpH+S/IVmSW4x1cIOgIhAIqrepYi59jMtiz/t+AbPtQDYxfuDMhQzB5SYiFafh45"}]},"_npmUser":{"name":"angrigo","email":"gab.angrisani@gmail.com"},"directories":{},"maintainers":[{"name":"angrigo","email":"gab.angrisani@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/capacitor-label-printer_0.0.2_1739021958279_0.5844106849394419"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-08T13:39:18.194Z","0.0.2":"2025-02-08T13:39:18.873Z","modified":"2025-02-08T13:39:19.166Z"},"maintainers":[{"name":"angrigo","email":"gab.angrisani@gmail.com"}],"description":"Provide a native interface to label printers","homepage":"https://github.com/adelantsoftware/capacitor-label-printer#readme","keywords":["brother","print","sdk","label","ecosystem:cordova","cordova-ios","cordova-android"],"repository":{"type":"git","url":"git+https://github.com/adelantsoftware/capacitor-label-printer.git"},"author":{"name":"Diga Systems"},"bugs":{"url":"https://github.com/adelantsoftware/capacitor-label-printer/issues"},"license":"MIT","readme":"# Cordova and Capacitor plugin for Brother Label Printers\n\n## Supports Android and iOS\n\nUses the Brother Print SDK for Android and iOS ...\n\nMore info can be found here, including a list of compatible printers:\nhttps://support.brother.com/g/s/es/dev/en/mobilesdk/download/index.html?c=us_ot&lang=en&comple=on&redirect=on\n\nAlready bundled is the following version:\n\n- Brother Print SDK for Android™ v3.5.1 (2020-07-16) which is in the `src/android/libs` dir.\n- Brother Print SDK for iPhone/iPad v4.0.2 (2020-09-08)\n\n## Installing\n\nIn your Cordova project, run the following command to install the plugin.\n\n```\ncordova plugin add git+https://github.com/adelantsoftware/capacitor-label-printer\n```\n\nor\n\n```\ncordova plugin add capacitor-label-printer\n```\n\nAnd then read [usage](#usage) below.\n\n## Help and Support\n\nPlease do not email me for support or help with this plugin, use the issue tracker link above, so everyone will benefit from community questions and involvement, and I don't have to answer the same questions over and over for many individuals.\n\nThis is a Cordova plugin, firstly. You should be familiar with the Cordova plugin system before you try to use this plugin. Fortunately, it's pretty straight forward and easy to understand.\n\nYou can [read more about Android plugin development for Cordova here](https://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html). Knowledge of all of these internals is not necessary, but it doesn't hurt to be familiar either.\n\nRead here to [learn how to use Cordova Plugins](https://cordova.apache.org/docs/en/latest/guide/cli/index.html#add-plugins).\n\n## Target mobile printers:\n\n```\nPocketJet PJ-722, PJ-723, PJ-762, PJ-763, PJ-763MFi, PJ-773\nPocketJet PJ-622, PJ-623, PJ-662, PJ-663\nPocketJet PJ-520, PJ-522, PJ-523, PJ-560, PJ-562, PJ-563\nMPrint MW-145MFi, MW-260MFi\nMPrint MW-140BT, MW-145BT, MW-260\nRJ-4030Ai, RJ-4030, RJ-4040\nTD-2020, TD-2120N, TD-2130N, TD-4000, TD-4100N\nQL-710W, QL-720NW, QL-810W, QL-820NWB, QL-1110NWB, QL-1115NWB,\nPT-E550W, PT-P750W\nRJ-3050, RJ-3150\nPT-E800W, PT-D800W, PT-E850TKW\nPT-P900W, PT-P950NW\n```\n\n**Tested models:** `QL-720NW`, `QL-820NWB`, `TD-2120N`\n\n(if you have tried this with other models, please update this list and send a pull request)\n\n## Supported interfaces (by this plugin):\n\n- Wi-Fi (Infrastructure mode)\n- Bluetooth (Android and iOS)\n- USB\n\n### BlueTooth notes:\n\nIf your app is supporting BlueTooth, you will need the following changes in you rproject:\n\n#### Android permissions\n\n```\n    <uses-permission android:name=\"android.permission.BLUETOOTH\" />\n    <uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />\n    <uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />\n```\n\n#### iOS\n\n- For iOS, you need to apply for an MFi PPID.\n  Please follow the steps at\n  https://secure6.brother.co.jp/mfi/Top.aspx\n\n- Code change in your cordova config\n\n```\n    <config-file parent=\"NSBluetoothPeripheralUsageDescription\" platform=\"ios\" target=\"*-Info.plist\">\n        <string>Bluetooth access for Brother label printer</string>\n    </config-file>\n    <config-file parent=\"NSBluetoothAlwaysUsageDescription\" platform=\"ios\" target=\"*-Info.plist\">\n        <string>Bluetooth access for Brother label printer</string>\n    </config-file>\n    <config-file parent=\"UISupportedExternalAccessoryProtocols\" platform=\"ios\" target=\"*-Info.plist\">\n        <array>\n            <string>com.brother.ptcbp</string>\n        </array>\n    </config-file>\n    <config-file parent=\"NSLocalNetworkUsageDescription\" platform=\"ios\" target=\"*-Info.plist\">\n        <string>Used to discover printers on your network</string>\n    </config-file>\n    <config-file parent=\"NSBonjourServices\" platform=\"ios\" target=\"*-Info.plist\">\n        <array>\n            <string>_printer._tcp</string>\n            <string>_pdl-datastream._tcp</string>\n            <string>_ipp._tcp</string>\n        </array>\n    </config-file>\n```\n\n## Usage\n\nSee here for JS interfaces to the plugin: `www/printer.js`\n\nThere are six available methods...\n\n- [findNetworkPrinters(success, failure)](#findnetworkprinters)\n- [findBluetoothPrinters(success, failure)](#findbluetoothprinters)\n- [findPrinters(success, failure)](#findprinters)\n- [setPrinter(printer, success, failure)](#setprinter)\n- [printViaSDK(data, success)](#printviasdk)\n- [sendUSBConfig(data, success)](#sendusbconfig)\n\n### findNetworkPrinters\n\nUpon success, [`findNetworkPrinters`](#findNetworkPrinters) will provide a list of printers that were discovered on the network (likely using WiFi). It is not considered an error for no printers to be found, and in this case the list will just be empty.\n\n```typescript\nfunction findNetworkPrinters(\n  success: (printers: Printer[]) => void,\n  failure: (reason: string) => void\n): void;\n```\n\n### findBluetoothPrinters\n\nUpon success, [`findBluetoothPrinters`](#findBluetoothPrinters) will provide a list of printers that were discovered that have already been paired via Bluetooth. It is not considered an error for no printers to be found, and in this case the list will just be empty.\n\n```typescript\nfunction findBluetoothPrinters(\n  success: (printers: Printer[]) => void,\n  failure: (reason: string) => void\n): void;\n```\n\n### findPrinters\n\n[`findPrinters`](#findPrinters) is a convenience function that will perform the actions of both [`findNetworkPrinters`](#findNetworkPrinters) and [`findBluetoothPrinters`](#findBluetoothPrinters), and combine the the results into a single continuous list.\n\n```typescript\nfunction findPrinters(\n  success: (printers: Printer[]) => void,\n  failure: (reason: string) => void\n): void;\n```\n\n### setPrinter\n\nmust be called before [`printViaSDK`](#printViaSDK). It takes a single object that should be one of the objects returned from [`findNetworkPrinters`](#findNetworkPrinters), [`findBluetoothPrinters`](#findBluetoothPrinters), or [`findPrinters`](#findPrinters). Upon successfully setting the printer, the success callback\nwill be invoked. Otherwise, the error callback will be invoked with a string for an error message.\n\n```typescript\nfunction setPrinter(\n  printer: Printer,\n  success: () => void,\n  failure: (reason: string) => void\n): void;\n```\n\n### printViaSDK\n\ntakes one parameter, which is a base64 encoded bitmap image. The result should be a status code that is passed directly from the SDK. The status codes are documnted in the Brother SDK Appendix in section 4.2.2.5.Error Code. If everything works, the response should be `\"ERROR_NONE\"`.\n\n**Clarification**:\n\n> A bitmap image in this case can be any image with an encoding that is supported by the platform.\n\n```typescript\nfunction printViaSDK(data: string, success: () => void): void;\n```\n\n### sendUSBConfig\n\ncalls the Brother SDK's `printFile` method. The expected input is a string containing raw print commands, which is written to a temporary file in the app cache directory, and is then sent to the `printFile` method and deleted afterwards. You will need a device that supports USB-OTG and a USB-OTG cable. On first run the app will request USB permissions, and it should be saved after that for subsequent prints. As-is, this method is used to send raw commands in PCL (Printer Control Language) to the printer... For example, to configure the network settings of the printer, etc... You will need to reach out to Brother for documentation of the PCL commands. You can probably find them by searching for \"[Brother Printer Command Reference](https://duckduckgo.com/?q=Brother+Printer+Command+Reference)\" and appending your model number. This method could be extended easily to accept other types of file input, so you could, for example, print JPG images, etc... See here for a simple way to generate a PJL file to reconfigure the network: https://github.com/gordol/PJL-Generator\n\n```typescript\nfunction sendUSBConfig(data: string, success: () => void): void;\n```\n\n### Interface Reference\n\n```typescript\ninterface Printer {\n  model: string; // Usually of the form 'QL_720NW' on Android\n  port: \"NET\" | \"BLUETOOTH\";\n  modelName: string; // Usually of the form 'Brother QL-720NW'\n  ipAddress?: string;\n  macAddress?: string;\n  serialNumber?: string;\n  nodeName?: string;\n  location?: string;\n  paperLabelName?: string; // 'W17H54'|'W17H87'|'W23H23'|'W29H42'|'W29H90'|'W38H90'|'W39H48'|'W52H29'|'W62H29'|'W62H100'|'W12'|'W29'|'W38'|'W50'|'W54'|'W62'|'W60H86'|'W54H29'|'W62RB'\n}\n```\n\n### Sample Code\n\n```\n    private setAndPrint(thePrinter: Printer, dataUrl: string) {\n\n        console.debug(`===== in setAndPrint===`)\n\n        thePrinter.orientation = 'LANDSCAPE'\n        thePrinter.paperLabelName = 'W62'\n        thePrinter.ipAddress = 'YOUR_IP_ADDRESS'\n\n        cordova.plugins.brotherPrinter.setPrinter(thePrinter, (success) => {\n            console.debug(`===== set printer ok`)\n\n            let separatorIdx: number = dataUrl.indexOf(',');\n\n            if (separatorIdx != -1) {\n                dataUrl = dataUrl.substring(separatorIdx + 1);\n            }\n\n            cordova.plugins.brotherPrinter.printViaSDK(dataUrl, (success) => {\n                console.debug(`===== in printViaSDK ok`)\n\n                if (success && success['result'] && success['result'] != \"ERROR_NONE\" && success['result'].indexOf('ERROR') != -1) {\n                    console.error(`Printing on ${this.toString(thePrinter)} returned message : ${JSON.stringify(success)}`)\n                } else {\n                    console.debug(`=====print via sdk ok!!!`)\n                    //this.toastService.showInfo(`Badge printed successfully`)\n                }\n\n\n            }, (err) => {\n                console.error(`Failed to print via sdk`)\n                console.error(`Printing failed on ${this.toString(thePrinter)} with message : ${JSON.stringify(err)}`)\n\n            })\n        }, (err) => {\n            console.error(`====error failed to set printer: \"${JSON.stringify(err)}\"`)\n            console.error(`Failed to set printer to ${this.toString(thePrinter)} with message : ${JSON.stringify(err)}`)\n\n        })\n\n\n        console.debug(`===== in setAndPrint END ===`)\n\n    }\n\n    private toString(thePrinter: Printer): string {\n        if (!thePrinter) {\n            return ''\n        }\n\n        return `ip:${thePrinter.ipAddress}, model:${thePrinter.model}, port: ${thePrinter.port}`\n    }\n\n}\n```\n\n## iOS notes:\n\n- You may get errors while compiling: you need to make sure the native lib is \"embed and sign\" .\n  see https://github.com/AbobosSoftware/cordova-plugin-brother-label-printer/issues/39\n\n- If you are getting errors about unsupported architectures, please look at\n  http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/\n","readmeFilename":"README.md"}