跳过内容

开始

GitHub

您可以使用我们的AI辅助设置来安装插件。将以下命令添加到您的AI工具中:Capgo技能。

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-document-scanner` plugin in my project.

如果您更喜欢手动设置,请运行以下命令安装插件并遵循以下平台特定的说明:

终端窗口
bun add @capgo/capacitor-document-scanner
bunx cap sync
import { DocumentScanner } from '@capgo/capacitor-document-scanner';

打开设备相机并启动文档扫描体验。

import { DocumentScanner } from '@capgo/capacitor-document-scanner';
await DocumentScanner.scanDocument();

类型参考

类型参考

ScanDocumentOptions

扫描文档选项
export interface ScanDocumentOptions {
/**
* Android only: quality of the cropped image from 0 - 100 (100 is best).
* @default 100
*/
croppedImageQuality?: number;
/**
* Allow the user to adjust the detected crop before saving.
* On iOS this forces the native VisionKit preview/editor after each capture using
* the private VisionKit navigation hooks needed to keep the scanner flow alive.
* On Android this enables ML Kit's crop adjustment flow.
* @default true
*/
letUserAdjustCrop?: boolean;
/**
* When enabled, shows the current scanned page before continuing so the user can
* review it and explicitly continue or finish the flow.
* On iOS this forces the native VisionKit preview/editor between captures.
* On Android this switches to a one-page-at-a-time flow between ML Kit sessions.
* The review/editor screen is still shown automatically when the scan limit is reached.
* @default false
*/
reviewCapturedDocument?: boolean;
/**
* Maximum number of documents to scan.
* On iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow
* can still stop earlier when you pass a smaller limit.
* On Android: customizable limit; defaults to 20 for performance (clamped 1-24).
* Set to 1 for single-scan mode where the scanner stops after one document.
* @default 20 on Android, 24 on iOS
*/
maxNumDocuments?: number;
/**
* Format to return scanned images in (file paths or base64 strings).
* @default ResponseType.ImageFilePath
*/
responseType?: ResponseType;
/**
* Brightness adjustment applied to scanned images.
* Range: -255 to 255 (0 = no change, positive = brighter, negative = darker)
* Useful for compensating low-light scans.
* @default 0
*/
brightness?: number;
/**
* Contrast adjustment applied to scanned images.
* Range: 0.0 to 10.0 (1.0 = no change, >1 = more contrast, <1 = less contrast)
* Helps improve text clarity in poorly lit scans.
* @default 1.0
*/
contrast?: number;
/**
* Android only: scanner mode that controls ML Kit features and filters.
* - 'base': Basic scan with crop/rotate, no filters or ML cleaning
* - 'base_with_filter': Adds grayscale and auto-enhancement filters
* - 'full': All features including ML-based image cleaning (erases stains, fingers, etc.)
* @default ScannerMode.Full
*/
scannerMode?: ScannerMode;
}

ScanDocumentResponse

扫描文档响应
export interface ScanDocumentResponse {
/**
* Scanned images in the requested response format.
*/
scannedImages?: string[];
/**
* Indicates whether the scan completed or was cancelled.
*/
status?: ScanDocumentResponseStatus;
/**
* Get the native Capacitor plugin version
*
* @returns {Promise<{ id: string }>} an Promise with version for this device
* @throws An error if the something went wrong
*/
getPluginVersion(): Promise<{ version: string }>;
}

ResponseType

响应类型
export enum ResponseType {
/**
* Return scanned images as base64-encoded strings.
*/
Base64 = 'base64',
/**
* Return scanned images as file paths on disk.
*/
ImageFilePath = 'imageFilePath',
}

ScannerMode

扫描器模式
export enum ScannerMode {
/**
* Basic document scanning with crop and rotate features only.
* No filters or ML-based enhancements.
*/
Base = 'base',
/**
* Basic features plus automatic filters (grayscale, auto-enhancement).
*/
BaseWithFilter = 'base_with_filter',
/**
* Full feature set including ML-based image cleaning.
* Automatically removes stains, fingers, and other artifacts.
*/
Full = 'full',
}

ScanDocumentResponseStatus

扫描文档响应状态
export enum ScanDocumentResponseStatus {
/**
* The scan completed successfully.
*/
Success = 'success',
/**
* The user cancelled the scan flow.
*/
Cancel = 'cancel',
}

真实数据来源

标题:真实数据来源

本页由插件生成 src/definitions.ts. 当公共 API 上游更改时,请重新运行同步。

从 Getting Started 开始

标题:从 Getting Started 开始

如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其与 使用 @capgo/capacitor-document-scanner 连接到使用 @capgo/capacitor-document-scanner, API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节,以及 设备 为设备的实现细节