Skip to content

Latest commit

 

History

History
142 lines (94 loc) · 4.29 KB

document-scan.md

File metadata and controls

142 lines (94 loc) · 4.29 KB

documentScan

Documentation: Chrome Document Scan API

A promise-based wrapper for the Chrome documentScan API.

Methods


isAvailableDocumentScan

isAvailableDocumentScan(method?: ApiMethodName<typeof chrome.documentScan>): boolean

The 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

cancelDocScanning(job: string): Promise<chrome.documentScan.CancelScanResponse<string>>

Cancels an ongoing document scan job.

closeDocScanner

closeDocScanner(scannerHandle: string): Promise<chrome.documentScan.CloseScannerResponse<string>>

Closes the document scanner associated with the specified scanner handle.

getDocScannerOptionGroups

getDocScannerOptionGroups(scannerHandle: string): Promise<chrome.documentScan.GetOptionGroupsResponse<string>>

Retrieves the available option groups for the specified document scanner.

getDocScannerList

getDocScannerList(filter: chrome.documentScan.DeviceFilter): Promise<chrome.documentScan.GetScannerListResponse>

Fetches a list of document scanners matching the given filter criteria.

openDocScanner

openDocScanner(scannerId: string): Promise<chrome.documentScan.OpenScannerResponse<string>>

Opens a document scanner by its ID, returning a handle for further operations.

readDocScanningData

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

docScanning(options: chrome.documentScan.ScanOptions): Promise<chrome.documentScan.ScanResults>

Performs a one-shot document scan with the specified options and returns the results.

setDocScannerOptions

setDocScannerOptions(
  scannerHandle: string,
  options: chrome.documentScan.OptionSetting[]
): Promise<chrome.documentScan.SetOptionsResponse<string>>

Sets multiple scanner options on the given scanner handle.

startDocScanning

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.