1# ohscan.h 2 3 4## Overview 5 6Enables applications to use CAPI to access scanners. 7 8**Since**: 12 9 10 11## Summary 12 13 14### Types 15 16| Name| Description| 17| -------- | -------- | 18| [Scan_ScannerDevice](#scan_scannerdevice) | Defines the device information of a scanner.| 19| [Scan_PictureScanProgress](#scan_picturescanprogress) | Defines the image scanning progress.| 20| [Scan_ScannerOptions](#scan_scanneroptions) | Defines the scanner options.| 21| [Scan_ScannerDiscoveryCallback](#scan_scannerdiscoverycallback) | Defines a callback to be invoked when a scanner is discovered.| 22 23 24### Enums 25 26| Name| Description| 27| -------- | -------- | 28| [Scan_ErrorCode](#scan_errorcode) | Enumerates the error codes.| 29 30 31### Functions 32 33| Name| Description| 34| -------- | -------- | 35| [OH_Scan_Init](#oh_scan_init) | Starts the scanning service, initializes the client, and establishes a connection with the scanning service.| 36| [OH_Scan_StartScannerDiscovery](#oh_scan_startscannerdiscovery) | Searches for scanners and registers a callback function to process the found scanners.| 37| [OH_Scan_OpenScanner](#oh_scan_openscanner) | Connects to a scanner.| 38| [OH_Scan_CloseScanner](#oh_scan_closescanner) | Disconnects from the scanner.| 39| [OH_Scan_GetScannerParameter](#oh_scan_getscannerparameter) | Obtains scanner settings.| 40| [OH_Scan_SetScannerParameter](#oh_scan_setscannerparameter) | Sets the option parameters of the scanner.| 41| [OH_Scan_StartScan](#oh_scan_startscan) | Starts the scanner.| 42| [OH_Scan_CancelScan](#oh_scan_cancelscan) | Cancels scanning.| 43| [OH_Scan_GetPictureScanProgress](#oh_scan_getpicturescanprogress) | Queries the image scanning progress.| 44| [OH_Scan_Exit](#oh_scan_exit) | Exits the scanning service and releases the client memory.| 45 46 47## Type Description 48 49 50### Scan_ScannerDevice 51 52**Description** 53 54Defines the device information of a scanner. 55 56**Since**: 12 57 58| Member | Description | 59| ------------ | -------- | 60| scannerId | Scanner ID.| 61| manufacturer | Manufacturer. | 62| model | Device model.| 63| discoverMode | Device discovery mode.| 64| serialNumber | Serial number. | 65 66### Scan_PictureScanProgress 67 68**Description** 69 70Defines the image scanning progress. 71 72**Since**: 12 73 74| Member | Description | 75| -------- | ----------------------- | 76| progress | Image scanning progress. The value ranges from 0 to 100.| 77| fd | Image file handle. | 78| isFinal | Whether the next image is available. | 79 80### Scan_ScannerOptions 81 82**Description** 83 84Defines the scanner options. 85 86**Since**: 12 87 88| Member | Description | 89| ------------ | ------------ | 90| titles | Option titles. | 91| descriptions | Descriptions of options.| 92| ranges | Option ranges. | 93| optionCount | Number of options. | 94 95### Scan_ScannerDiscoveryCallback 96 97**Description** 98 99Defines a callback to be invoked when a scanner is discovered. 100 101**Since**: 12 102 103| Parameter | Description | 104| ----------- | ---------- | 105| devices | Scanner.| 106| deviceCount | Number of scanners. | 107 108 109 110## Enum Description 111 112 113### Scan_ErrorCode 114 115**Description** 116 117Enumerates the error codes. 118 119**Since**: 12 120 121| Value| Description| 122| -------- | -------- | 123| SCAN_ERROR_NONE | Operation successful.| 124| SCAN_ERROR_NO_PERMISSION | Permission denied.| 125| SCAN_ERROR_INVALID_PARAMETER | Invalid parameter.| 126| SCAN_ERROR_GENERIC_FAILURE | Internal error.| 127| SCAN_ERROR_RPC_FAILURE | RPC communication error.| 128| SCAN_ERROR_SERVER_FAILURE | Server error.| 129| SCAN_ERROR_UNSUPPORTED | Operation not supported.| 130| SCAN_ERROR_CANCELED | Operation canceled.| 131| SCAN_ERROR_DEVICE_BUSY | Device busy.| 132| SCAN_ERROR_INVALID | Invalid operation.| 133| SCAN_ERROR_JAMMED | Paper jam in feeder.| 134| SCAN_ERROR_NO_DOCS | Out of paper.| 135| SCAN_ERROR_COVER_OPEN | Scanner cover opened.| 136| SCAN_ERROR_IO_ERROR | Scanner I/O operation error.| 137| SCAN_ERROR_NO_MEMORY | Insufficient memory.| 138 139 140## Function Description 141 142 143### OH_Scan_Init() 144 145```cpp 146int32_t OH_Scan_Init(); 147``` 148 149**Description** 150 151Starts the scanning service, initializes the client, and establishes a connection with the scanning service. 152 153**System capability**: ohos.permission.PRINT 154 155**Since**: 12 156 157**Returns** 158 159**Scan_ERROR_NONE**: Operation successful. 160 161**SCAN_ERROR_NO_PERMISSION**: Permission denied. 162 163**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 164 165**SCAN_ERROR_SERVER_FAILURE**: Server error. 166 167### OH_Scan_StartScannerDiscovery() 168 169```cpp 170int32_t OH_Scan_StartScannerDiscovery(Scan_ScannerDiscoveryCallback callback); 171``` 172 173**Description** 174 175Searches for scanners and registers a callback function to process the found scanners. 176 177**System capability**: ohos.permission.PRINT 178 179**Since**: 12 180 181**Parameters** 182 183| Name | Description | 184| -------- | -------------------------- | 185| callback | Callback function for scanner discovery.| 186 187**Returns** 188 189**Scan_ERROR_NONE**: Operation successful. 190 191**SCAN_ERROR_NO_PERMISSION**: Permission denied. 192 193**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 194 195**SCAN_ERROR_SERVER_FAILURE**: Server error. 196 197### OH_Scan_OpenScanner() 198 199```cpp 200int32_t OH_Scan_OpenScanner(const char* scannerId); 201``` 202 203**Description** 204 205Connects to a scanner. 206 207**System capability**: ohos.permission.PRINT 208 209**Since**: 12 210 211**Parameters** 212 213| Name | Description | 214| --------- | ---------- | 215| scannerId | Scanner ID.| 216 217**Returns** 218 219**Scan_ERROR_NONE**: Operation successful. 220 221**SCAN_ERROR_NO_PERMISSION**: Permission denied. 222 223**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 224 225**SCAN_ERROR_SERVER_FAILURE**: Server error. 226 227**SCAN_ERROR_DEVICE_BUSY**: Scanner busy. 228 229**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 230 231**SCAN_ERROR_IO_ERROR**: Scanner I/O operation error. 232 233**SCAN_ERROR_NO_MEMORY**: Insufficient scanner memory. 234 235### OH_Scan_CloseScanner() 236 237```cpp 238int32_t OH_Scan_CloseScanner(const char* scannerId); 239``` 240 241**Description** 242 243Disconnects from the scanner. 244 245**System capability**: ohos.permission.PRINT 246 247**Since**: 12 248 249**Parameters** 250 251| Name | Description | 252| --------- | ---------- | 253| scannerId | Scanner ID.| 254 255**Returns** 256 257**Scan_ERROR_NONE**: Operation successful. 258 259**SCAN_ERROR_NO_PERMISSION**: Permission denied. 260 261**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 262 263**SCAN_ERROR_SERVER_FAILURE**: Server error. 264 265**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 266 267### OH_Scan_GetScannerParameter() 268 269```cpp 270Scan_ScannerOptions* OH_Scan_GetScannerParameter(const char* scannerId, int32_t* errorCode); 271``` 272 273**Description** 274 275Obtains the scanner setting options. The memory is automatically released when returned structure points to [OH_Scan_Exit](#oh_scan_exit). Only one copy of each scanner model is stored in the memory. 276 277**System capability**: ohos.permission.PRINT 278 279**Since**: 12 280 281**Parameters** 282 283| Name | Description | 284| --------- | ---------- | 285| scannerId | Scanner ID.| 286| errorCode | Error code. | 287 288**Returns** 289 290**Scan_ERROR_NONE**: Operation successful. 291 292**SCAN_ERROR_NO_PERMISSION**: Permission denied. 293 294**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 295 296**SCAN_ERROR_SERVER_FAILURE**: Server error. 297 298### OH_Scan_SetScannerParameter() 299 300```cpp 301int32_t OH_Scan_SetScannerParameter(const char* scannerId, const int32_t option, const char* value); 302``` 303 304**Description** 305 306Sets the option parameters of the scanner. The option values are obtained through the [OH_Scan_GetScannerParameter](#oh_scan_getscannerparameter) API. 307 308**System capability**: ohos.permission.PRINT 309 310**Since**: 12 311 312**Parameters** 313 314| Name | Description | 315| --------- | ---------- | 316| scannerId | Scanner ID.| 317| option | Option Number. | 318| value | Option value. | 319 320**Returns** 321 322**Scan_ERROR_NONE**: Operation successful. 323 324**SCAN_ERROR_NO_PERMISSION**: Permission denied. 325 326**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 327 328**SCAN_ERROR_SERVER_FAILURE**: Server error. 329 330**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 331 332### OH_Scan_StartScan() 333 334```cpp 335int32_t OH_Scan_StartScan(const char* scannerId, bool batchMode); 336``` 337 338**Description** 339 340Starts a scanner. 341 342**System capability**: ohos.permission.PRINT 343 344**Since**: 12 345 346**Parameters** 347 348| Name | Description | 349| --------- | ---------- | 350| scannerId | Scanner ID.| 351| batchMode | Batch processing mode.| 352 353**Returns** 354 355**Scan_ERROR_NONE**: Operation successful. 356**SCAN_ERROR_NO_PERMISSION**: Permission denied. 357 358**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 359 360**SCAN_ERROR_SERVER_FAILURE**: Server error. 361 362**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 363 364**SCAN_ERROR_JAMMED**: Paper jam in feeder. 365 366**SCAN_ERROR_NO_DOCS**: Scanner out of paper. 367 368**SCAN_ERROR_COVER_OPEN**: Scanner cover opened. 369 370**SCAN_ERROR_IO_ERROR**: Scanner I/O operation error. 371 372**SCAN_ERROR_NO_MEMORY**: Insufficient scanner memory. 373 374**SCAN_ERROR_DEVICE_BUSY**: Scanner busy. 375 376### OH_Scan_CancelScan() 377 378```cpp 379int32_t OH_Scan_CancelScan(const char* scannerId); 380``` 381 382**Description** 383 384Cancels scanning. 385 386**System capability**: ohos.permission.PRINT 387 388**Since**: 12 389 390**Parameters** 391 392| Name | Description | 393| --------- | ---------- | 394| scannerId | Scanner ID.| 395 396**Returns** 397 398**Scan_ERROR_NONE**: Operation successful. 399 400**SCAN_ERROR_NO_PERMISSION**: Permission denied. 401 402**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 403 404**SCAN_ERROR_SERVER_FAILURE**: Server error. 405 406**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 407 408### OH_Scan_GetPictureScanProgress() 409 410```cpp 411int32_t OH_Scan_GetPictureScanProgress(const char* scannerId, Scan_PictureScanProgress* prog); 412``` 413 414**Description** 415 416Queries the image scanning progress. 417 418**System capability**: ohos.permission.PRINT 419 420**Since**: 12 421 422**Parameters** 423 424| Name | Description | 425| --------- | ------------ | 426| scannerId | Scanner ID. | 427| prog | Image scanning progress.| 428 429**Returns** 430 431**Scan_ERROR_NONE**: Operation successful. 432 433**SCAN_ERROR_NO_PERMISSION**: Permission denied. 434 435**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 436 437**SCAN_ERROR_SERVER_FAILURE**: Server error. 438 439**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 440 441**SCAN_ERROR_JAMMED**: Paper jam in feeder. 442 443**SCAN_ERROR_NO_DOCS**: Scanner out of paper. 444 445**SCAN_ERROR_COVER_OPEN**: Scanner cover opened. 446 447**SCAN_ERROR_IO_ERROR**: Scanner I/O operation error. 448 449**SCAN_ERROR_NO_MEMORY**: Insufficient scanner memory. 450 451**SCAN_ERROR_DEVICE_BUSY**: Scanner busy. 452 453### OH_Scan_Exit() 454 455```cpp 456int32_t OH_Scan_Exit(); 457``` 458 459**Description** 460 461Exits the scanning service, clear the client memory, and cancel the registered scanning callback function. 462 463**System capability**: ohos.permission.PRINT 464 465**Since**: 12 466 467**Returns** 468 469**Scan_ERROR_NONE**: Operation successful. 470 471**SCAN_ERROR_NO_PERMISSION**: Permission denied. 472 473**SCAN_ERROR_RPC_FAILURE**: RPC communication error. 474 475**SCAN_ERROR_SERVER_FAILURE**: Server error. 476 477**SCAN_ERROR_INVALID_PARAMETER**: Invalid parameter. 478