Welcome Getting started API Reference Samples
Welcome Getting started API Reference Samples

chrome.printing

Important: This API works only on Chrome OS
  • Description

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

  • Permissions
    printing

Summary

Types

GetPrinterInfoResponse

Properties

  • capabilities
    object optional

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

  • The status of the printer.

Printer

Properties

  • description
    string

    The human-readable description of the printer.

  • id
    string

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

  • isDefault
    boolean

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

  • name
    string

    The name of the printer.

  • recentlyUsedRank
    number optional

    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.

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

  • uri
    string

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

SubmitJobRequest

Properties

  • 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.

SubmitJobResponse

Properties

  • jobId
    string optional

    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.

  • The status of the request.

JobStatus

Status of the print job.

Enum

"PENDING", "IN_PROGRESS", "FAILED", "CANCELED", or "PRINTED"

PrinterSource

The source of the printer.

Enum

"USER", or "POLICY"

PrinterStatus

The status of the printer.

Enum

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

SubmitJobStatus

The status of submitJob request.

Enum

"OK", or "USER_REJECTED"

Properties

MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE

The maximum number of times that getPrinterInfo can be called per minute.

Value

number 20

MAX_SUBMIT_JOB_CALLS_PER_MINUTE

The maximum number of times that submitJob can be called per minute.

Value

number 20

Methods

cancelJob

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

Cancels previously submitted job.

Parameters

  • jobId
    string

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

  • callback
    function

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

    () => {...}

getPrinterInfo

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

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

getPrinters

chrome.printing.getPrinters(callback: function)

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

Parameters

  • callback
    function

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

    (printers: Printer[]) => {...}

submitJob

chrome.printing.submitJob(request: SubmitJobRequest, callback: function)

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

Parameters

Events

onJobStatusChanged

chrome.printing.onJobStatusChanged.addListener(listener: function)

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

Event

  • listener
    function

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

    (jobId: string, status: JobStatus) => {...}
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.