chrome.printerProvider

Description: The chrome.printerProvider API exposes events used by print manager to query printers controlled by extensions, to query their capabilities and to submit print jobs to these printers.
Availability: Since Chrome 44.
Permissions: "printerProvider"

Summary

Types
PrinterInfo
Events
onGetPrintersRequested
onGetUsbPrinterInfoRequested
onGetCapabilityRequested
onPrintRequested

Types

PrinterInfo

properties
string id

Unique printer ID.

string name

Printer's human readable name.

string (optional) description

Printer's human readable description.

Events

onGetPrintersRequested

Event fired when print manager requests printers provided by extensions.

addListener

chrome.printerProvider.onGetPrintersRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(function resultCallback) {...};
function resultCallback

Callback to return printer list. Every listener must call callback exactly once.

The resultCallback parameter should be a function that looks like this:

function(array of PrinterInfo printerInfo) {...};
array of PrinterInfo printerInfo

onGetUsbPrinterInfoRequested

Since Chrome 45.

Event fired when print manager requests information about a USB device that may be a printer.

Note: An application should not rely on this event being fired more than once per device. If a connected device is supported it should be returned in the onGetPrintersRequested event.

addListener

chrome.printerProvider.onGetUsbPrinterInfoRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function( usb.Device device, function resultCallback) {...};
usb.Device device

The USB device.

function resultCallback

Callback to return printer info. The receiving listener must call callback exactly once. If the parameter to this callback is undefined that indicates that the application has determined that the device is not supported.

The resultCallback parameter should be a function that looks like this:

function( PrinterInfo printerInfo) {...};
PrinterInfo (optional) printerInfo

onGetCapabilityRequested

Event fired when print manager requests printer capabilities.

addListener

chrome.printerProvider.onGetCapabilityRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(string printerId, function resultCallback) {...};
string printerId

Unique ID of the printer whose capabilities are requested.

function resultCallback

Callback to return device capabilities in CDD format. The receiving listener must call callback exectly once.

The resultCallback parameter should be a function that looks like this:

function(object capabilities) {...};
object capabilities

Device capabilities in CDD format.

onPrintRequested

Event fired when print manager requests printing.

addListener

chrome.printerProvider.onPrintRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object printJob, function resultCallback) {...};
object printJob

The printing request parameters.

string printerId

ID of the printer which should handle the job.

string title

The print job title.

object ticket

Print ticket in CJT format.

string contentType

The document content type. Supported formats are "application/pdf" and "image/pwg-raster".

Blob document

Blob containing the document data to print. Format must match |contentType|.

function resultCallback

Callback that should be called when the printing request is completed.

The resultCallback parameter should be a function that looks like this:

function(enum of "OK", "FAILED", "INVALID_TICKET", or "INVALID_DATA" result) {...};
enum of "OK", "FAILED", "INVALID_TICKET", or "INVALID_DATA" result
OK
Operation completed successfully.
FAILED
General failure.
INVALID_TICKET
Print ticket is invalid. For example, ticket is inconsistent with capabilities or extension is not able to handle all settings from the ticket.
INVALID_DATA
Document is invalid. For example, data may be corrupted or the format is incompatible with the extension.