chrome.printing
- Description
Use the
chrome.printing
API to send print jobs to printers installed on Chromebook. - Permissions
printing
Summary
- Types
- Properties
- Methods
chrome.printing.cancelJob(jobId: string, callback: function)
chrome.printing.getPrinterInfo(printerId: string, callback: function)
chrome.printing.getPrinters(callback: function)
chrome.printing.submitJob(request: SubmitJobRequest, callback: function)
- Events
Types
GetPrinterInfoResponse
Properties
- capabilitiesobject optional
Printer capabilities in CDD format. The property may be missing.
- status
The status of the printer.
Printer
Properties
- descriptionstring
The human-readable description of the printer.
- idstring
The printer's identifier; guaranteed to be unique among printers on the device.
- isDefaultboolean
The flag which shows whether the printer fits DefaultPrinterSelection rules. Note that several printers could be flagged.
- namestring
The name of the printer.
- recentlyUsedRanknumber 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.
- source
The source of the printer (user or policy configured).
- uristring
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
- jobIdstring 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.
- status
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"
Properties
MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE
The maximum number of times that getPrinterInfo
can be called per minute.
Value
MAX_SUBMIT_JOB_CALLS_PER_MINUTE
The maximum number of times that submitJob
can be called per minute.
Value
Methods
cancelJob
chrome.printing.cancelJob(jobId: string, callback: function)
Cancels previously submitted job.
Parameters
- jobIdstring
The id of the print job to cancel. This should be the same id received in a
SubmitJobResponse
. - callbackfunction
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
- printerIdstring
- callbackfunction
The callback parameter should be a function that looks like this:
(response: GetPrinterInfoResponse) => {...}
- response
getPrinters
chrome.printing.getPrinters(callback: function)
Returns the list of available printers on the device. This includes manually added, enterprise and discovered printers.
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
- request
- callbackfunction
The callback parameter should be a function that looks like this:
(response: SubmitJobResponse) => {...}
- response
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.