Class: Printer

Printer

new Printer(device)

Represents a Zebra Printer, wrapping the BrowserPrint.Device class

Client API Level 2
Parameters:
Name Type Description
device BrowserPrint.Device BrowserPrint.Device object describing this device

Classes

Configuration
Info
Status

Methods

clearRequestQueue()

Clears all remaining requests in the queue. This does not cancel the currently running request

getConfiguration(successopt, failureopt) → {Promise}

Queued

Sends a request to the printer, then builds and returns Zebra.Printer.Configuration object from the response. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
success function <optional>
A callback function on success, which has the Zebra.Printer.Configuration object passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will return the Zebra.Printer.Configuration object. Otherwise returns nothing.
Type
Promise

getConvertedResource(resource, optionsopt, successopt, failureopt) → {Promise}

Retrieves the resource and converts it into a printable form. Converted resource will be returned as string with a format dependent on printer command language requested and capabilities of the host platform.

Client API Level 4
Parameters:
Name Type Attributes Description
resource string | blob The resource to be printed. Accepts a URL as a string, or a blob of an already loaded image file.
options object <optional>
Options for converting the resource provided.
Properties
Name Type Attributes Description
featureKey string <optional>
The licensing key for the file conversion. Currently, only converting from a PDF file requires a licensing key
toFormat string <optional>
The format the file should be converted to. Options are zpl, cpcl, kpl, and none. Default value is zpl.
fromFormat string <optional>
The file type of the resource to convert from. If not specified, the file extension will be used to determine file type.
resize.width int <optional>
The width the image should be resized to
resize.height int <optional>
The height the image should be resized to
fitTo.width int <optional>
Scale the image so that it fits into a rectangle described by fitTo.width and fitTo.height, maintaining aspect ratio.
fitTo.height int <optional>
Scale the image so that it fits into a rectangle described by fitTo.width and fitTo.height, maintaining aspect ratio.
scale float <optional>
Scale the image by the this factor.
success function <optional>
A callback function on success with the converted resource passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise object that returns the converted resource. Otherwise returns nothing.
Type
Promise

getInfo(successopt, failureopt) → {Promise}

Queued

Sends a request to the printer, then builds and returns a Zebra.Printer.Info object from response. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
success function <optional>
A callback function on success, which has the Zebra.Printer.Info object passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will return the Zebra.Printer.Info object. Otherwise returns nothing.
Type
Promise

getSGD(setting, successopt, failureopt) → {Promise}

Queued

Get the value of an 'SGD' setting. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
setting string The 'SGD' setting to retrieve
success function <optional>
A callback function on success, which has the value of the setting passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will output the completed printer command. Otherwise returns nothing.
Type
Promise

getStatus(successopt, failureopt) → {Promise}

Queued

Sends a request to the printer, then builds and returns a Zebra.Printer.Status object from response. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
success function <optional>
A callback function on success, which has the Zebra.Printer.Status object passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will return the Zebra.Printer.Status object. Otherwise returns nothing.
Type
Promise

isPrinterReady(successopt, failureopt) → {Promise}

Checks and reports whether the printer is ready to print.

Client API Level 2
Parameters:
Name Type Attributes Description
success function <optional>
A callback function called if the printer is ready to print, passing the status message. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function called if the printer is not ready to print, passing the error message, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise object. Otherwise returns nothing.
Type
Promise

printImageAsLabel(resource, optionsopt, successopt, failureopt) → {Promise}

Prints an image resource as a label, automatically resizing the image to best fill the print width and label length. Image will be scaled to the largest possible size while still entirely fitting within the printable area of the label, according to the Zebra.Printer.Configuration retrieved from the printer. This function requires that the API has successfully retrieved the printer configuration before calling.

Client API Level 4
Parameters:
Name Type Attributes Description
resource string | blob The resource to be printed. Accepts a URL as a string, or a blob of an already loaded image file.
options object <optional>
Options for converting the resource.
Properties
Name Type Attributes Description
featureKey string <optional>
The licensing key for the file conversion. Currently, only converting from a PDF file requires a licensing key
toFormat string <optional>
The format the file should be converted to. Options are zpl, cpcl, kpl, and none. Default value is zpl.
fromFormat string <optional>
The file type of the resource to convert from. If not specified, the file extension will be used to determine file type.
success function <optional>
A callback function on success. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise object. Otherwise returns nothing.
Type
Promise

query(command, successopt, failureopt) → {Promise}

Queued

Sends a command to the printer, then reads back the response. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2

Parameters:
Name Type Attributes Description
command string The query command to send to the printer
success function <optional>
A callback function on success, which has the Zebra.Printer.Status object passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will return the Zebra.Printer.Status object. Otherwise returns nothing.
Type
Promise

setSGD(setting, value, successopt, failureopt) → {Promise}

Queued

Sets an 'SGD' settings value on the printer. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
setting string The setting to set the value of
value string The value the setting should be set to
success function <optional>
A callback function on success. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that resolve when setting the value has completed. Otherwise returns nothing
Type
Promise

setThenGetSGD(setting, value, successopt, failureopt) → {Promise}

Queued

Set, then Get the value of an 'SGD' setting. This query to the printer is synchronized so that the last query response is received before this query is sent. This means all synchronized queries will be sent and received in the order they are called.

Client API Level 2
Parameters:
Name Type Attributes Description
setting string The 'SGD' setting to to set and then retrieve
value string The value to set the 'SGD' setting to to
success function <optional>
A callback function on success, which has the value of the setting passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise that will output the completed printer command. Otherwise returns nothing.
Type
Promise

storeConvertedResource(resource, optionsopt, successopt, failureopt) → {Promise}

Retrieves the resource and converts it into a storeable form, storing it on the printer. The path the resource was stored at on the printer will be passed to the success function as a string.

Client API Level 4
Parameters:
Name Type Attributes Description
resource string | blob The resource to be stored. Accepts a URL as a string, or a blob of an already loaded image file.
options object <optional>
Options for converting the provided resource.
Properties
Name Type Attributes Description
featureKey string <optional>
The licensing key for the file conversion. Currently, only converting from a PDF file requires a licensing key
toFormat string <optional>
The format the file should be converted to. Options are zpl, cpcl, kpl, and none. Default value is zpl.
fromFormat string <optional>
The file type of the resource to convert from. If not specified, the file extension will be used to determine file type.
resize.width int <optional>
The width the image should be resized to
resize.height int <optional>
The height the image should be resized to
fitTo.width int <optional>
Scale the image so that it fits into a rectangle described by fitTo.width and fitTo.height, maintaining aspect ratio.
fitTo.height int <optional>
Scale the image so that it fits into a rectangle described by fitTo.width and fitTo.height, maintaining aspect ratio.
storageName string The name of the stored file
scale float <optional>
Scale the image by the this factor.
success function <optional>
A callback function on success with the storage location path passed to it. Omitting the success and failure callbacks will automatically setup a Promise instead
failure function <optional>
A callback function on failure, which has the error message passed to it as a string. Omitting the success and failure callbacks will automatically setup a Promise instead
Returns:
If no callback functions are supplied, returns a Promise object that returns the storage location path. Otherwise returns nothing.
Type
Promise