Use the DocumentScanner API
DocumentScanner Example
Compatibility and Requirements
Considerations and Limitations
Previous Versions
A Lightning web component can use a device’s camera and optical character recognition (OCR) to scan documents. When a document is successfully scanned, text data extracted from the scanned document is returned to the Lightning web component that invoked it. DocumentScanner recognizes printed text and handwritten form factors. However, DocumentScanner provides the most accurate results when scanning printed text compared handwritten text, which varies on the legibility of handwritten characters.
DocumentScanner results are returned in two formats:
Scanning is performed locally on the mobile device, and doesn’t need a network connection. However, DocumentScanner requires access to APIs implemented in platform-native code that are available only within compatible Salesforce mobile apps.
DocumentScanner does not and cannot function when running in a web browser, whether on a desktop or mobile device.
Important
To add document scanning features to a Lightning web component, use the DocumentScanner API.
Here’s an example of a Lightning web component that uses DocumentScanner to capture text data from an image.
Compatibility and Requirements
DocumentScanner is a JavaScript module that provides an API to Lightning web components to make mobile hardware and platform (operating system) features available in JavaScript. It requires access to device hardware and device platform APIs. This access is only available when DocumentScanner runs within a compatible Salesforce mobile app. It does not and cannot function when running in a standard web browser, whether the browser runs on a desktop or mobile device.
Considerations and Limitations
Consider these guidelines and limitations when developing features that use the DocumentScanner API.