APD Preexisting JavaScript Object

RhoElements 2.x API

Overview

The APD Preexisting JavaScript Object contains read only properties and methods for interacting with the Adaptive Printer Driver. If you have configured 'PreloadLegacyAPD' to be '1' the JavaScript object 'apd' will be inserted automatically into your page's DOM by RhoElements.

Syntax

APD (Preexisting JavaScript Object) <META> Syntax
apd.PSExternal(iCommand, 'strParameter');

Methods

Name Parameters Returns
PSExternal
Used to send commands via the Zebra Adaptive Printer Driver without returning a result.
Name: iCommand
Values: Four digit numeric value, See APD documentation for values.
Description: A numeric value representing the required Adaptive Printer Driver function ID.

Name: strParameter
Values: String, See APD documentation for values
Description: String containing function specific parameters / data to be passed to the Adaptive Printer Driver.
N/A
PSExternalEx
Used to send commands via the Zebra Adaptive Printer Driver, returning the result of the command.
Name: iCommand
Values: Four digit numeric value, See APD documentation for values
Description: A numeric value representing the required Adaptive Printer Driver function ID.

Name: strParameter
Values: String, See APD documentation for values
Description: String containing function specific parameters / data to be passed to the Adaptive Printer Driver.
Integer representing the result of sending the command (See APD documentation)
PSGetLastMessage
Returns the last error message encountered by the Zebra Adaptive Printer Driver.
String representing the last error message from the APD

Remarks

More Documentation

More documentation on the APD is available at http://docs.rhomobile.com

Backwards Compatibility

The APD Preexisting JavaScript Object provides backwards compatibility with code written for PocketBrowser and also supports the syntax below. Because RhoElements inserts the object 'apd' on the page automatically when 'PreloadLegacyAPD' is configured to be '1' you can not create your own objects by this name, see below:


<script>
    //  Old PocketBrowser syntax supported by APD
    var myObj = new ActiveXObject("PocketBrowser.NarrowBand");

    //  Note: var apd = new ... will fail because the object already exists on the page.
    myObj.PSExternal(261, '2350C');
</script>

APD version

The APD version returned by the Cmd_PSGetVersion command (decimal code 260) is not assumed to be the same across the supported platforms, even though the supported capabilities are the same. For instance, at the time of writing, the current version for Windows is 'Zebra APD V2.19.06', whereas the version for Android is Zebra APD V1.00.00A, with the terminating 'A' standing for Android.

Embedded Commands

If an embedded command with a malformed code is sent via APD, for instance 'apd.PSExternal(266, "$$[CMD:-0104]$$")', Windows APD will not generate any output to the printer, but on Android the malformed command will be treated as a common string and therefore printed out.

Printing on the MC2100

Additional steps are required to pair your MC2100 via Bluetooth for printing. Please refer to the "Bluetooth Printing" section in the MC2100 User Guide

Requirements

RhoElements Version 1.0.0 or above
Supported Devices All devices
Minimum Requirements None.
Persistence Executes immediately.

HTML/JavaScript Examples

The Following example shows usage PSExternal:


<script>
    var printerID = '2350C';
    apd.PSExternal(261, printerID);
</script>

The Following example shows usage PSExternalEx and PSGetLastMessage:


<script>
    if(apd.PSExternalEx(257, 'Hello World') > 0)
    {
      alert(apd.PSGetLastMessage());
    }
</script>