chrome.printing

Description: Use the chrome.printing API to send print jobs to printers installed on Chromebook.
Availability: Since Chrome 81.
Permissions: "printing"

Important: This API works only on Chrome OS.

Summary

Properties
MAX_SUBMIT_JOB_CALLS_PER_MINUTE
MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE
Methods
submitJob chrome.printing.submitJob(object request, function callback)
cancelJob chrome.printing.cancelJob(string jobId, function callback)
getPrinters chrome.printing.getPrinters(function callback)
getPrinterInfo chrome.printing.getPrinterInfo(string printerId, function callback)
Events
onJobStatusChanged

Properties

20 chrome.printing.MAX_SUBMIT_JOB_CALLS_PER_MINUTE The maximum number of times that submitJob can be called per minute.
20 chrome.printing.MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE The maximum number of times that getPrinterInfo can be called per minute.

Methods

submitJob

chrome.printing.submitJob(object request, function callback)

Submits the job for print. If the extension is not listed in PrintingAPIExtensionsWhitelist policy, the user will be prompted to accept the print job.

Parameters
object request
printerProvider.PrintJob job

The print job to be submitted. The only supported content type is "application/pdf", and the CJT ticket shouldn't include FitToPageTicketItem, PageRangeTicketItem, ReverseOrderTicketItem and VendorTicketItem fields since they are irrelevant for native printing. All other fields must be present.

function callback

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

function(object response) {...};
object response
enum of "OK", or "USER_REJECTED" status

The status of the request.

OK
Sent print job request is accepted.
USER_REJECTED
Sent print job request is rejected by the user.
string (optional) jobId

The id of created print job. This is a unique identifier among all print jobs on the device. If status is not OK, jobId will be null.

cancelJob

chrome.printing.cancelJob(string jobId, function callback)

Cancels previously submitted job.

Parameters
string jobId

The id of the print job to cancel. This should be the same id received in a SubmitJobResponse.

function callback

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

function() {...};

getPrinters

chrome.printing.getPrinters(function callback)

Returns the list of available printers on the device. This includes manually added, enterprise and discovered printers.

Parameters
function callback

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

function(array of object printers) {...};
array of object printers

Properties of each object

string id

The printer's identifier; guaranteed to be unique among printers on the device.

string name

The name of the printer.

string description

The human-readable description of the printer.

string uri

The printer URI. This can be used by extensions to choose the printer for the user.

enum of "USER", or "POLICY" source

The source of the printer (user or policy configured).

USER
Printer was added by user.
POLICY
Printer was added via policy.
boolean isDefault

The flag which shows whether the printer fits DefaultPrinterSelection rules. Note that several printers could be flagged.

integer (optional) recentlyUsedRank

The value showing how recent the printer was used for printing from Chrome. The lower the value is the more recent the printer was used. The minimum value is 0. Missing value indicates that the printer wasn't used recently. This value is guaranteed to be unique amongst printers.

getPrinterInfo

chrome.printing.getPrinterInfo(string printerId, function callback)

Returns the status and capabilities of the printer in CDD format. This call will fail with a runtime error if no printers with given id are installed.

Parameters
string printerId
function callback

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

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

Printer capabilities in CDD format. The property may be missing.

enum of "DOOR_OPEN", "TRAY_MISSING", "OUT_OF_INK", "OUT_OF_PAPER", "OUTPUT_FULL", "PAPER_JAM", "GENERIC_ISSUE", "STOPPED", "UNREACHABLE", or "AVAILABLE" status

The status of the printer.

DOOR_OPEN
The door of the printer is open. Printer still accepts print jobs.
TRAY_MISSING
The tray of the printer is missing. Printer still accepts print jobs.
OUT_OF_INK
The printer is out of ink. Printer still accepts print jobs.
OUT_OF_PAPER
The printer is out of paper. Printer still accepts print jobs.
OUTPUT_FULL
The output area of the printer (e.g. tray) is full. Printer still accepts print jobs.
PAPER_JAM
The printer has a paper jam. Printer still accepts print jobs.
GENERIC_ISSUE
Some generic issue. Printer still accepts print jobs.
STOPPED
The printer is stopped and doesn't print but still accepts print jobs.
UNREACHABLE
The printer is unreachable and doesn't accept print jobs.
AVAILABLE
The printer is available.

Events

onJobStatusChanged

Event fired when the status of the job is changed. This is only fired for the jobs created by this extension.

addListener

chrome.printing.onJobStatusChanged.addListener(function callback)
Parameters
function callback

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

function(string jobId, enum of "PENDING", "IN_PROGRESS", "FAILED", "CANCELED", or "PRINTED" status) {...};
string jobId
enum of "PENDING", "IN_PROGRESS", "FAILED", "CANCELED", or "PRINTED" status
PENDING
Print job is received on Chrome side but was not processed yet.
IN_PROGRESS
Print job is sent for printing.
FAILED
Print job was interrupted due to some error.
CANCELED
Print job was canceled by the user or via API.
PRINTED
Print job was printed without any errors.