Documentation: Chrome Document Scan API
A promise-based wrapper for the Chrome documentScan API.
- isAvailableDocumentScan()
- cancelDocScanning(job)
- closeDocScanner(scannerHandle)
- getDocScannerOptionGroups(scannerHandle)
- getDocScannerList(filter)
- openDocScanner(scannerId)
- readDocScanningData(job)
- docScanning(options)
- setDocScannerOptions(scannerHandle, options)
- startDocScanning(scannerHandle, options)
isAvailableDocumentScan(method?: ApiMethodName<typeof chrome.documentScan>): booleanThe optional method is a native function name, for example isAvailableDocumentScan("scan").
Import the public ApiMethodName type from @addon-core/browser for your own typed helpers.
This checks callable presence without invoking the method; permissions and argument support still require handling.
Returns true when the documentScan namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable.
Neither form verifies permissions, argument support, or a successful operation. See method availability.
import {isAvailableDocumentScan} from "@addon-core/browser";
if (isAvailableDocumentScan()) {
// The namespace is present; handle operation-specific failures when using it.
}cancelDocScanning(job: string): Promise<chrome.documentScan.CancelScanResponse<string>>
Cancels an ongoing document scan job.
closeDocScanner(scannerHandle: string): Promise<chrome.documentScan.CloseScannerResponse<string>>
Closes the document scanner associated with the specified scanner handle.
getDocScannerOptionGroups(scannerHandle: string): Promise<chrome.documentScan.GetOptionGroupsResponse<string>>
Retrieves the available option groups for the specified document scanner.
getDocScannerList(filter: chrome.documentScan.DeviceFilter): Promise<chrome.documentScan.GetScannerListResponse>
Fetches a list of document scanners matching the given filter criteria.
openDocScanner(scannerId: string): Promise<chrome.documentScan.OpenScannerResponse<string>>
Opens a document scanner by its ID, returning a handle for further operations.
readDocScanningData(job: string): Promise<chrome.documentScan.ReadScanDataResponse<string>>
Reads the next chunk of data from an ongoing scan job. Note: A successful response with zero-length data indicates the scanner is still working; try again shortly. When the job completes, the response result will be EOF and may contain a final data chunk.
docScanning(options: chrome.documentScan.ScanOptions): Promise<chrome.documentScan.ScanResults>
Performs a one-shot document scan with the specified options and returns the results.
setDocScannerOptions(
scannerHandle: string,
options: chrome.documentScan.OptionSetting[]
): Promise<chrome.documentScan.SetOptionsResponse<string>>
Sets multiple scanner options on the given scanner handle.
startDocScanning(
scannerHandle: string,
options: chrome.documentScan.StartScanOptions
): Promise<chrome.documentScan.StartScanResponse<string>>
Starts a scan on an open scanner using the provided options and returns a job handle.