whale.printerProvider
Description: | The whale.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" |
## 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
`whale.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](/extensions/printerProvider#type-PrinterInfo) printerInfo) {...};`
| array of [PrinterInfo](/extensions/printerProvider#type-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](/extensions/printerProvider#event-onGetPrintersRequested) event.
#### addListener
`whale.printerProvider.onGetUsbPrinterInfoRequested.addListener(function callback)`
| Parameters |
|---|
| function | callback |
The _callback_ parameter should be a function that looks like this:
`function( [usb.Device](/extensions/#type-Device) device, function resultCallback) {...};`
| [usb.Device](/extensions/#type-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](/extensions/printerProvider#type-PrinterInfo) printerInfo) {...};`
| [PrinterInfo](/extensions/printerProvider#type-PrinterInfo) | (optional) printerInfo | |
|---|---|---|
|
|
### onGetCapabilityRequested
Event fired when print manager requests printer capabilities.
#### addListener
`whale.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](https://developers.google.com/cloud-print/docs/cdd#cdd). 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](https://developers.google.com/cloud-print/docs/cdd#cdd).
|
|
|
### onPrintRequested
Event fired when print manager requests printing.
#### addListener
`whale.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](https://developers.google.com/cloud-print/docs/cdd#cjt).
|
| 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.