chrome.printing

Description

Use the chrome.printing API to send print jobs to printers installed on Chromebook.

Permissions

printing

Availability

Chrome 81+ ChromeOS only

All chrome.printing methods and events require you to declare the "printing" permission in the extension manifest. For example:

{
  "name": "My extension",
  ...
  "permissions": [
    "printing"
  ],
  ...
}

Examples

The examples below demonstrate using each of the methods in the printing namespace. This code is copied from or based on the api-samples/printing in the extensions-samples Github repo.

cancelJob()

This example uses the onJobStatusChanged handler to hide a 'cancel' button when the jobStatus is neither PENDING or IN_PROGRESS. Note that on some networks or when a Chromebook is connected directly to the printer, these states may pass too quickly for the cancel button to be visible long enough to be called. This is greatly simplified printing example.

chrome.printing.onJobStatusChanged.addListener((jobId, status) => {
  const cancelButton = document.getElementById("cancelButton");
  cancelButton.addEventListener('click', () => {
    chrome.printing.cancelJob(jobId).then((response) => {
      if (response !==