API: Print to Bixolon Printer

Send print requests to a Bixolon printer. Print elements on the page, 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
  • iOS/iPadOS Permissions
    • Bluetooth - more on enabling specific iOS/iPadOS permissions here.
  • Physical Hardware


Triggers via API Functions

Print HTML Element on Page

This function prints an element on the page based on the id attribute. For example, if your page has <p id="print">Print me</p> you can print only this <p> tag by setting the "elementId" parameter to the id "print".

Format
kp_BixolonPrinter_printHTMLElement(elementId, cut);
		
Parameters
  • elementId - [string] id attribute of the HTML element 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
    Triggers If the print is successful, the app will immediately call kp_BixolonPrinter_printDidFinish. If an error occurs, the app will immediately call kp_BixolonPrinter_printDidFailWithError, passing more detail about the error as a parameter.


    Print HTML String

    This function prints a specific HTML string that you define. This is useful if you do not want to include the printed element on the page. For example, you can define this as <p style="font-size: 30px">Print me</p>.

    Format
    kp_BixolonPrinter_printHTMLString(htmlString, cut);
    		
    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
    Triggers If the print is successful, the app will immediately call kp_BixolonPrinter_printDidFinish. If an error occurs, the app will immediately call kp_BixolonPrinter_printDidFailWithError, passing more detail about the error as a parameter.


    Print Page via URL

    This function prints a specific page or document from a URL. This is useful if you want to print a PDF, for example. Note: this cannot print files stored locally on the device.

    Format
    kp_BixolonPrinter_printHTMLString(url, cut);
    		
    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
    Triggers If the print is successful, the app will immediately call kp_BixolonPrinter_printDidFinish. If an error occurs, the app will immediately call kp_BixolonPrinter_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_BixolonPrinter_printDidFinish();
    		


    When Printing Fails

    This callback is run when a print call is successful.

    Format
    kp_BixolonPrinter_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/bixolon-api
    • To download a .zip of sample code, click here.

    Change Log

    • Added in version 8.5.

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