API: Print to Brother QL Series Thermal Printer

Send print requests to a Brother QL-Series printer. Print HTML strings or documents at a different URL.

Requirements

Kiosk Pro Enterprise

  • Integration of our JavaScript API into your webpage
    • Sample code to run within the app and download for integration into your own project is available here.
    • Best practices for working with the JavaScript API are available here.
  • App Settings
    • Content > JavaScript API > Access JavaScript API = By Import
    • Printing > Brother QL Series Label Printer > Enable Brother Printer = On
    • Printing > Brother QL Series Label Printer > Select Printer = printer connected
  • iOS/iPadOS Permissions
    • Bluetooth - more on enabling specific iOS/iPadOS permissions here.
  • Physical Hardware
    • Brother QL-Series thermal printer - more information available here.


Triggers via API Functions


Print HTML String

This function prints a specific HTML string that you define. For example, you can define this as <p style="font-size: 30px">Print me</p>.

Format
kp_BrotherPrinter_printHTMLString(htmlString, cut, preview);
		
Parameters
  • htmlString - [string] the HTML string to print.
  • cut - [integer] determines whether to cut the paper after it is printed. Possible options:
    • 0 - [integer] will not cut the paper
    • 1 - [integer] will cut the paper
  • preview - [integer] determines whether to show a preview of the printed result. Possible options:
    • 0 - [integer] will not show preview and printing will occur as normal
    • 1 - [integer] will display a preview, printing will not occur
    Triggers If the print is successful, the app will immediately call kp_BrotherPrinter_printDidFinish. If an error occurs, the app will immediately call kp_BrotherPrinter_printDidFailWithError, passing more detail about the error as a parameter.


    Print Page via URL

    This function prints a specific HTML page from a URL. Note: this cannot print files stored locally on the device.

    Format
    kp_BrotherPrinter_printDocumentAtURL(url, cut, preview);
    		
    Parameters
  • url - [string] the URL of the page you want to print.
  • cut - [integer] determines whether to cut the paper after it is printed. Possible options:
    • 0 - [integer] will not cut the paper
    • 1 - [integer] will cut the paper
  • preview - [integer] determines whether to show a preview of the printed result. Possible options:
    • 0 - [integer] will not show preview and printing will occur as normal
    • 1 - [integer] will display a preview, printing will not occur
    Triggers If the print is successful, the app will immediately call kp_BrotherPrinter_printDidFinish. If an error occurs, the app will immediately call kp_BrotherPrinter_printDidFailWithError, passing more detail about the error as a parameter.


    Notifications via API Callbacks

    When Printing is Successful

    This callback is run when a print call is successful.

    Format
    kp_BrotherPrinter_printDidFinish();
    		


    When Printing Fails

    This callback is run when a print call is successful.

    Format
    kp_BrotherPrinter_printDidFailWithError(error);
    		
    Return values
    • error - [associative array] details about why the print call failed. Includes:
      • code - [string] the error code.
      • description - [string] description of the error.
      • domain - [string] where the error occurred.
      • debugDescription - [string] a fully detailed description of the error.


    Sample Code

    • This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
    • To run sample code, set the app's homepage to https://www.kioskgroup.com/brother-api
    • To download a .zip of sample code, click here.

    Change Log

    • Added in version 10.1.

    Still stuck? How can we help? How can we help?