| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 22-Oct-2025 | - | 35 | 32 | ||
| entry/ | 22-Oct-2025 | - | 1,022 | 937 | ||
| hvigor/ | 22-Oct-2025 | - | 37 | 36 | ||
| sceenshots/ | 22-Oct-2025 | - | ||||
| .gitignore | D | 22-Oct-2025 | 133 | 12 | 12 | |
| README_zh.md | D | 22-Oct-2025 | 4.9 KiB | 134 | 86 | |
| build-profile.json5 | D | 22-Oct-2025 | 1.2 KiB | 50 | 49 | |
| hvigorfile.ts | D | 22-Oct-2025 | 842 | 21 | 5 | |
| oh-package-lock.json5 | D | 22-Oct-2025 | 1.5 KiB | 42 | 41 | |
| oh-package.json5 | D | 22-Oct-2025 | 832 | 25 | 24 |
README_zh.md
1# 扫描仪应用demo 2 3### 介绍 4本示例使用@ohos.scan接口拉起[打印框架](https://gitee.com/openharmony/print_print_fwk)下的扫描服务,由扫描服务加载扫描仪驱动,完成扫描仪的发现与连接、获取扫描仪选项、设置扫描仪参数、启动扫描仪、获取扫描图片进度、取消扫描的功能。 5 6### 界面预览 7 8 9使用说明 10 111.本示例是测试扫描框架接口能力,扫描仪驱动基于sane-backends开发。 12 132.首页的按钮点击后调用扫描框架对应的接口。 14 153.启动扫描后,可以通过图片预览按钮查看扫描出的图片。 16 17### 工程目录 18 19``` 20ScanNapiInterfaceDemo 21├── AppScope 22│ └── app.json5 //APP信息配置文件 23├── entry/src/main 24│ ├── ets 25│ │ ├── entryability 26│ │ ├── scan 27│ │ │ ├── log.ts //日志库 28│ │ │ ├── scan.ts //扫描接口库 29│ │ ├── pages 30│ │ │ ├── Index.ets //应用界面 31│ └── module.json5 32│ 33├── entry/src/ohosTest //测试用例 34│ ├── ets/test 35│ │ ├── Ability.test.ets 36│ │ ├── List.test.ets //测试列表 37│ │ ├── Scan.test.ets //扫描接口测试 38│ └── module.json5 39``` 40 41### 具体实现 42 43* 该示例分为7个接口: 44 * 搜索扫描仪 45 * 使用@ohos.scan中API 12接口scan.on注册发现回调函数,然后调用@ohos.scan中的scan.getScannerList接口开启扫描仪搜索,当发现到扫描仪时,会通过on注册的回调函数,将扫描仪设备信息回调到应用。 46 * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) 47 * 参考接口:[@ohos.scan] 48 49 * 连接扫描仪 50 51 * 使用@ohos.scan中API 12接口scan.openScanner连接扫描仪,传入的参数是扫描仪的id。 52 * 源码链接:[scan.ts](./entry/src/main/ets/scan/scan.ts) 53 * 参考接口:[@ohos.scan] 54 55 * 启动扫描仪 56 57 * 使用@ohos.scan中API 12接口scan.startScan启动扫描任务,传入的参数是扫描仪的id和是否开启批处理扫描模式。 58 59 * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) 60 61 * 参考接口:[@ohos.scan] 62 63 * 取消扫描 64 65 * 使用@ohos.scan中API 12接口scan.cancelScan取消扫描任务,传入的参数是扫描仪的id。 66 67 * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) 68 69 * 参考接口:[@ohos.scan] 70 * 查询扫描进度 71 72 * 使用@ohos.scan中API 12接口scan.getScanProgress查询扫描仪扫描图片的进度。 73 74 * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) 75 76 * 参考接口:@ohos.scan 77 * 获取扫描仪选项 78 79 * 使用@ohos.scan中API 12接口scan.getScanOption查询扫描仪有多少个选项,getScanOptionDesc获取每一个选项具体的描述信息。 80 81 * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) 82 83 * 参考接口:@ohos.scan 84 * 设置扫描仪参数 85 86 * 使用@ohos.scan中API 12接口scan.setScanOption设置某一台扫描仪的选项参数。 87 88 * 源码链接,[scan.ts](./entry/src/main/ets/scan/scan.ts) 89 90 * 参考接口:@ohos.scan 91 92### 相关权限 93 94[ohos.permission.PRINT] 95 96[ohos.permission.MANAGE_PRINT_JOB] 97 98### 依赖 99 1001.API12版本SDK的@ohos.scan接口。 101 1022.基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends)开发的扫描仪驱动以及对应厂商型号的扫描仪设备。 103 104### 约束与限制 105 1061.本示例仅支持标准系统上运行,支持设备:RK3568。 107 1082.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0) 109 1103.本示例需要使用DevEco Studio 版本号(5.0.3.403)及以上版本才可编译运行。 111 1124.运行本示例需要连接扫描仪,下载扫描仪对应的驱动。 113 114### 下载 115 116如需单独下载本工程,执行如下命令: 117 118``` 119git init 120git config core.sparsecheckout true 121echo code/BasicFeature/Print/ScanNapiInterfaceDemo/ > .git/info/sparse-checkout 122git remote add origin https://gitee.com/openharmony/applications_app_samples.git 123git pull 124``` 125 126### 构建说明 127 1281.需要基于[sane-backends](https://gitee.com/openharmony-sig/third_party_backends/)完成扫描仪驱动的开发。 129 1302.扫描仪驱动通过驱动安装应用安装到指定路径。 131 1323.本工程通过Build Hap(s)/APP(s)完成编译构建,然后安装。 133 1344.通过局域网或有线等物理方式连接扫描仪后即可通过主界面的相关按钮实现扫描仪的发现和连接等功能。