1# @ohos.print (打印) 2 3该模块为基本打印的操作API,提供调用基础打印功能的接口。 4 5> **说明:** 6> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 7 8## 导入模块 9 10```ts 11import { print } from '@kit.BasicServicesKit'; 12``` 13 14## PrintTask 15 16打印任务完成后的事件监听回调接口类。 17 18### on 19 20on(type: 'block', callback: Callback<void>): void 21 22注册打印完成后的监听,使用callback回调。 23 24**需要权限:** ohos.permission.PRINT 25 26**系统能力:** SystemCapability.Print.PrintFramework 27 28**参数:** 29| **参数名** | **类型** | **必填** | **说明** | 30| -------- | -------- | -------- | -------- | 31| type | string | 是 | 注册监听,<br/>监听字段:block,<br/>表示打印阻塞 | 32| callback | Callback<void> | 是 | 打印完成后处于响应状态的回调 | 33 34**错误码:** 35 36以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 37 38| 错误码ID | 错误信息 | 39| -------- | ------------------------------------------- | 40| 201 | the application does not have permission to call this function. | 41| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 42 43**示例:** 44 45```ts 46import { print } from '@kit.BasicServicesKit'; 47import { BusinessError } from '@ohos.base'; 48 49let file = ['file://data/print/a.png', 'file://data/print/b.png']; 50print.print(file).then((printTask: print.PrintTask) => { 51 printTask.on('block', () => { 52 console.log('print state is block'); 53 }) 54 // ... 55}).catch((error: BusinessError) => { 56 console.log('print err ' + JSON.stringify(error)); 57}) 58``` 59 60### on 61 62on(type: 'succeed', callback: Callback<void>): void 63 64注册打印完成后的监听,使用callback回调。 65 66**需要权限:** ohos.permission.PRINT 67 68**系统能力:** SystemCapability.Print.PrintFramework 69 70**参数:** 71| **参数名** | **类型** | **必填** | **说明** | 72| -------- | -------- | -------- | -------- | 73| type | string | 是 | 注册监听,<br/>监听字段:succeed,<br/>表示打印成功 | 74| callback | Callback<void> | 是 | 打印完成后处于响应状态的回调 | 75 76**错误码:** 77 78以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 79 80| 错误码ID | 错误信息 | 81| -------- | ------------------------------------------- | 82| 201 | the application does not have permission to call this function. | 83| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 84 85**示例:** 86 87```ts 88import { print } from '@kit.BasicServicesKit'; 89import { BusinessError } from '@ohos.base'; 90 91let file = ['file://data/print/a.png', 'file://data/print/b.png']; 92print.print(file).then((printTask: print.PrintTask) => { 93 printTask.on('succeed', () => { 94 console.log('print state is succeed'); 95 }) 96 // ... 97}).catch((error: BusinessError) => { 98 console.log('print err ' + JSON.stringify(error)); 99}) 100``` 101 102### on 103 104on(type: 'fail', callback: Callback<void>): void 105 106注册打印完成后的监听,使用callback回调。 107 108**需要权限:** ohos.permission.PRINT 109 110**系统能力:** SystemCapability.Print.PrintFramework 111 112**参数:** 113| **参数名** | **类型** | **必填** | **说明** | 114| -------- | -------- | -------- | -------- | 115| type | string | 是 | 注册监听,<br/>监听字段:fail,<br/>表示打印失败 | 116| callback | Callback<void> | 是 | 打印完成后处于响应状态的回调 | 117 118**错误码:** 119 120以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 121 122| 错误码ID | 错误信息 | 123| -------- | ------------------------------------------- | 124| 201 | the application does not have permission to call this function. | 125| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 126 127**示例:** 128 129```ts 130import { print } from '@kit.BasicServicesKit'; 131import { BusinessError } from '@ohos.base'; 132 133let file = ['file://data/print/a.png', 'file://data/print/b.png']; 134print.print(file).then((printTask: print.PrintTask) => { 135 printTask.on('fail', () => { 136 console.log('print state is fail'); 137 }) 138 // ... 139}).catch((error: BusinessError) => { 140 console.log('print err ' + JSON.stringify(error)); 141}) 142``` 143 144### on 145 146on(type: 'cancel', callback: Callback<void>): void 147 148注册打印完成后的监听,使用callback回调。 149 150**需要权限:** ohos.permission.PRINT 151 152**系统能力:** SystemCapability.Print.PrintFramework 153 154**参数:** 155| **参数名** | **类型** | **必填** | **说明** | 156| -------- | -------- | -------- | -------- | 157| type | string | 是 | 注册监听,<br/>监听字段:cancel,<br/>表示打印取消 | 158| callback | Callback<void> | 是 | 打印完成后处于响应状态的回调 | 159 160**错误码:** 161 162以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 163 164| 错误码ID | 错误信息 | 165| -------- | ------------------------------------------- | 166| 201 | the application does not have permission to call this function. | 167| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 168 169**示例:** 170 171```ts 172import { print } from '@kit.BasicServicesKit'; 173import { BusinessError } from '@ohos.base'; 174 175let file = ['file://data/print/a.png', 'file://data/print/b.png']; 176print.print(file).then((printTask: print.PrintTask) => { 177 printTask.on('cancel', () => { 178 console.log('print state is cancel'); 179 }) 180 // ... 181}).catch((error: BusinessError) => { 182 console.log('print err ' + JSON.stringify(error)); 183}) 184``` 185 186### off 187 188off(type: 'block', callback?: Callback<void>): void 189 190取消打印完成后的监听,使用callback回调。 191 192**需要权限:** ohos.permission.PRINT 193 194**系统能力:** SystemCapability.Print.PrintFramework 195 196**参数:** 197| **参数名** | **类型** | **必填** | **说明** | 198| -------- | -------- | -------- | -------- | 199| type | string | 是 | 取消监听,<br/>监听字段:block,<br/>表示打印阻塞 | 200| callback | Callback<void> | 否 | 取消相应状态监听成功后的回调 | 201 202**错误码:** 203 204以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 205 206| 错误码ID | 错误信息 | 207| -------- | ------------------------------------------- | 208| 201 | the application does not have permission to call this function. | 209| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 210 211**示例:** 212 213```ts 214import { print } from '@kit.BasicServicesKit'; 215import { BusinessError } from '@ohos.base'; 216 217let file = ['file://data/print/a.png', 'file://data/print/b.png']; 218print.print(file).then((printTask: print.PrintTask) => { 219 printTask.off('block', () => { 220 console.log('unregister state block'); 221 }) 222 // ... 223}).catch((error: BusinessError) => { 224 console.log('print err ' + JSON.stringify(error)); 225}) 226``` 227 228### off 229 230off(type: 'succeed', callback?: Callback<void>): void 231 232取消打印完成后的监听,使用callback回调。 233 234**需要权限:** ohos.permission.PRINT 235 236**系统能力:** SystemCapability.Print.PrintFramework 237 238**参数:** 239| **参数名** | **类型** | **必填** | **说明** | 240| -------- | -------- | -------- | -------- | 241| type | string | 是 | 取消监听,<br/>监听字段:succeed,<br/>表示打印成功 | 242| callback | Callback<void> | 否 | 取消相应状态监听成功后的回调 | 243 244**错误码:** 245 246以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 247 248| 错误码ID | 错误信息 | 249| -------- | ------------------------------------------- | 250| 201 | the application does not have permission to call this function. | 251| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 252 253**示例:** 254 255```ts 256import { print } from '@kit.BasicServicesKit'; 257import { BusinessError } from '@ohos.base'; 258 259let file = ['file://data/print/a.png', 'file://data/print/b.png']; 260print.print(file).then((printTask: print.PrintTask) => { 261 printTask.off('succeed', () => { 262 console.log('unregister state succeed'); 263 }) 264 // ... 265}).catch((error: BusinessError) => { 266 console.log('print err ' + JSON.stringify(error)); 267}) 268``` 269 270### off 271 272off(type: 'fail', callback?: Callback<void>): void 273 274取消打印完成后的监听,使用callback回调。 275 276**需要权限:** ohos.permission.PRINT 277 278**系统能力:** SystemCapability.Print.PrintFramework 279 280**参数:** 281| **参数名** | **类型** | **必填** | **说明** | 282| -------- | -------- | -------- | -------- | 283| type | string | 是 | 取消监听,<br/>监听字段:fail,<br/>表示打印失败 | 284| callback | Callback<void> | 否 | 取消相应状态监听成功后的回调 | 285 286**错误码:** 287 288以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 289 290| 错误码ID | 错误信息 | 291| -------- | ------------------------------------------- | 292| 201 | the application does not have permission to call this function. | 293| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 294 295**示例:** 296 297```ts 298import { print } from '@kit.BasicServicesKit'; 299import { BusinessError } from '@ohos.base'; 300 301let file = ['file://data/print/a.png', 'file://data/print/b.png']; 302print.print(file).then((printTask: print.PrintTask) => { 303 printTask.off('fail', () => { 304 console.log('unregister state fail'); 305 }) 306 // ... 307}).catch((error: BusinessError) => { 308 console.log('print err ' + JSON.stringify(error)); 309}) 310``` 311 312### off 313 314off(type: 'cancel', callback?: Callback<void>): void 315 316取消打印完成后的监听,使用callback回调。 317 318**需要权限:** ohos.permission.PRINT 319 320**系统能力:** SystemCapability.Print.PrintFramework 321 322**参数:** 323| **参数名** | **类型** | **必填** | **说明** | 324| -------- | -------- | -------- | -------- | 325| type | string | 是 | 取消监听,<br/>监听字段:cancel,<br/>表示打印取消 | 326| callback | Callback<void> | 否 | 取消相应状态监听成功后的回调 | 327 328**错误码:** 329 330以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 331 332| 错误码ID | 错误信息 | 333| -------- | ------------------------------------------- | 334| 201 | the application does not have permission to call this function. | 335| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 336 337**示例:** 338 339```ts 340import { print } from '@kit.BasicServicesKit'; 341import { BusinessError } from '@ohos.base'; 342 343let file = ['file://data/print/a.png', 'file://data/print/b.png']; 344print.print(file).then((printTask: print.PrintTask) => { 345 printTask.off('cancel', () => { 346 console.log('unregister state cancel'); 347 }) 348 // ... 349}).catch((error: BusinessError) => { 350 console.log('print err ' + JSON.stringify(error)); 351}) 352``` 353 354## PrintDocumentAdapter<sup>11+</sup> 355 356第三方应用程序实现此接口来渲染要打印的文件。 357 358### onStartLayoutWrite 359 360onStartLayoutWrite(jobId: string, oldAttrs: PrintAttributes, newAttrs: PrintAttributes, fd: number, writeResultCallback: (jobId: string, writeResult: PrintFileCreationState) => void): void 361 362打印服务会通过本接口将一个空的pdf文件的文件描述符传给三方应用,由三方应用使用新的打印参数更新待打印文件,更新文件完成后通过本接口的回调方法writeResultCallback通知打印服务。 363 364**需要权限:** ohos.permission.PRINT 365 366**系统能力:** SystemCapability.Print.PrintFramework 367 368**参数:** 369| **参数名** | **类型** | **必填** | **说明** | 370| -------- | -------- | -------- | -------- | 371| jobId | string | 是 | 表示打印任务ID | 372| oldAttrs | PrintAttributes | 是 | 表示旧打印参数 | 373| newAttrs | PrintAttributes | 是 | 表示新打印参数 | 374| fd | number | 是 | 表示打印文件传给接口调用方的pdf文件的文件描述符。 | 375| writeResultCallback | (jobId: string, writeResult: PrintFileCreationState) | 是 | 表示三方应用使用新的打印参数更新待打印文件完成后的回调 | 376 377**错误码:** 378 379以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 380 381| 错误码ID | 错误信息 | 382| -------- | ------------------------------------------- | 383| 201 | the application does not have permission to call this function. | 384| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 385 386**示例:** 387 388```ts 389import { print } from '@kit.BasicServicesKit'; 390import { BusinessError } from '@ohos.base'; 391 392class MyPrintDocumentAdapter implements print.PrintDocumentAdapter { 393 onStartLayoutWrite(jobId: string, oldAttrs: print.PrintAttributes, newAttrs: print.PrintAttributes, fd: number, 394 writeResultCallback: (jobId: string, writeResult: print.PrintFileCreationState) => void) { 395 writeResultCallback(jobId, print.PrintFileCreationState.PRINT_FILE_CREATED); 396 }; 397 onJobStateChanged(jobId: string, state: print.PrintDocumentAdapterState) { 398 if (state == print.PrintDocumentAdapterState.PREVIEW_DESTROY) { 399 console.log('PREVIEW_DESTROY'); 400 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_SUCCEED) { 401 console.log('PRINT_TASK_SUCCEED'); 402 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_FAIL) { 403 console.log('PRINT_TASK_FAIL'); 404 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_CANCEL) { 405 console.log('PRINT_TASK_CANCEL'); 406 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_BLOCK) { 407 console.log('PRINT_TASK_BLOCK'); 408 } 409 } 410} 411``` 412 413### onJobStateChanged 414 415onJobStateChanged(jobId: string, state: PrintDocumentAdapterState): void 416 417实现这个接口来监听打印任务状态的改变。 418 419**需要权限:** ohos.permission.PRINT 420 421**系统能力:** SystemCapability.Print.PrintFramework 422 423**参数:** 424| **参数名** | **类型** | **必填** | **说明** | 425| -------- | -------- | -------- | -------- | 426| jobId | string | 是 | 表示打印任务ID | 427| state | PrintDocumentAdapterState | 是 | 表示打印任务更改为该状态 | 428 429**错误码:** 430 431以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 432 433| 错误码ID | 错误信息 | 434| -------- | ------------------------------------------- | 435| 201 | the application does not have permission to call this function. | 436| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 437 438**示例:** 439 440```ts 441import { print } from '@kit.BasicServicesKit'; 442import { BusinessError } from '@ohos.base'; 443 444class MyPrintDocumentAdapter implements print.PrintDocumentAdapter { 445 onStartLayoutWrite(jobId: string, oldAttrs: print.PrintAttributes, newAttrs: print.PrintAttributes, fd: number, 446 writeResultCallback: (jobId: string, writeResult: print.PrintFileCreationState) => void) { 447 writeResultCallback(jobId, print.PrintFileCreationState.PRINT_FILE_CREATED); 448 }; 449 onJobStateChanged(jobId: string, state: print.PrintDocumentAdapterState) { 450 if (state == print.PrintDocumentAdapterState.PREVIEW_DESTROY) { 451 console.log('PREVIEW_DESTROY'); 452 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_SUCCEED) { 453 console.log('PRINT_TASK_SUCCEED'); 454 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_FAIL) { 455 console.log('PRINT_TASK_FAIL'); 456 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_CANCEL) { 457 console.log('PRINT_TASK_CANCEL'); 458 } else if (state == print.PrintDocumentAdapterState.PRINT_TASK_BLOCK) { 459 console.log('PRINT_TASK_BLOCK'); 460 } 461 } 462} 463``` 464 465## print 466 467print(files: Array<string>, callback: AsyncCallback<PrintTask>): void 468 469打印接口,传入文件进行打印,使用callback异步回调。 470 471**需要权限:** ohos.permission.PRINT 472 473**系统能力:** SystemCapability.Print.PrintFramework 474 475**参数:** 476| **参数名** | **类型** | **必填** | **说明** | 477| -------- | -------- | -------- | -------- | 478| files | Array<string> | 是 | 待打印文件列表,支持图片(.jpg .png .gif .bmp .webp)和pdf。系统应用传入uri时,需先调用uriPermissionManager.grantUriPermission()接口给打印应用授权,此接口为系统接口。三方应用建议使用[print](#print11-2)。 | 479| callback | AsyncCallback<PrintTask> | 是 | 异步获取打印完成之后的回调 | 480 481**错误码:** 482 483以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 484 485| 错误码ID | 错误信息 | 486| -------- | ------------------------------------------- | 487| 201 | the application does not have permission to call this function. | 488| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 489 490**示例:** 491 492```ts 493import { print } from '@kit.BasicServicesKit'; 494import { BusinessError } from '@ohos.base'; 495 496//传入文件的uri 497let files = ['file://data/print/a.png', 'file://data/print/b.png']; 498//或者传入fd 499//let files = ['fd://1', 'fd://2']; 500print.print(files, (err: BusinessError, printTask: print.PrintTask) => { 501 if (err) { 502 console.log('print err ' + JSON.stringify(err)); 503 } else { 504 printTask.on('succeed', () => { 505 console.log('print state is succeed'); 506 }) 507 // ... 508 } 509}) 510``` 511 512## print 513 514print(files: Array<string>): Promise<PrintTask> 515 516打印接口,传入文件进行打印,使用Promise异步回调。 517 518**需要权限:** ohos.permission.PRINT 519 520**系统能力:** SystemCapability.Print.PrintFramework 521 522**参数:** 523| **参数名** | **类型** | **必填** | **说明** | 524| -------- | -------- | -------- | -------- | 525| files | Array<string> | 是 | 待打印文件列表,支持图片(.jpg .png .gif .bmp .webp)和pdf。系统应用传入uri时,需先调用uriPermissionManager.grantUriPermission()接口给打印应用授权,此接口为系统接口。三方应用建议使用[print](#print11-2)。 | 526 527**返回值:** 528| **类型** | **说明** | 529| -------- | -------- | 530| Promise<PrintTask> | 打印完成结果 | 531 532**错误码:** 533 534以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 535 536| 错误码ID | 错误信息 | 537| -------- | ------------------------------------------- | 538| 201 | the application does not have permission to call this function. | 539| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 540 541**示例:** 542 543```ts 544import { print } from '@kit.BasicServicesKit'; 545import { BusinessError } from '@ohos.base'; 546 547//传入文件的uri 548let files = ['file://data/print/a.png', 'file://data/print/b.png']; 549//或者传入fd 550//let files = ['fd://1', 'fd://2']; 551print.print(files).then((printTask: print.PrintTask) => { 552 printTask.on('succeed', () => { 553 console.log('print state is succeed'); 554 }) 555 // ... 556}).catch((error: BusinessError) => { 557 console.log('print err ' + JSON.stringify(error)); 558}) 559``` 560 561## print<sup>11+</sup> 562 563print(files: Array<string>, context: Context, callback: AsyncCallback<PrintTask>): void 564 565打印接口,传入文件进行打印,使用callback异步回调。 566 567**需要权限:** ohos.permission.PRINT 568 569**系统能力:** SystemCapability.Print.PrintFramework 570 571**参数:** 572| **参数名** | **类型** | **必填** | **说明** | 573| -------- | -------- | -------- | -------- | 574| files | Array<string> | 是 | 待打印文件列表,支持图片(.jpg .png .gif .bmp .webp)和pdf。系统应用传入uri时,需先调用uriPermissionManager.grantUriPermission()接口给打印应用授权,此接口为系统接口。三方应用建议使用[print](#print11-2)。 | 575| context | Context | 是 | 用于拉起系统打印界面的UIAbilityContext | 576| callback | AsyncCallback<PrintTask> | 是 | 异步获取打印完成之后的回调 | 577 578**错误码:** 579 580以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 581 582| 错误码ID | 错误信息 | 583| -------- | ------------------------------------------- | 584| 201 | the application does not have permission to call this function. | 585| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 586 587**示例:** 588 589```ts 590import { print } from '@kit.BasicServicesKit'; 591import { BusinessError } from '@ohos.base'; 592 593//传入文件的uri 594let files = ['file://data/print/a.png', 'file://data/print/b.png']; 595//或者传入fd 596//let files = ['fd://1', 'fd://2']; 597let context = getContext(this); 598print.print(files, context, (err: BusinessError, printTask: print.PrintTask) => { 599 if (err) { 600 console.log('print err ' + JSON.stringify(err)); 601 } else { 602 printTask.on('succeed', () => { 603 console.log('print state is succeed'); 604 }) 605 // ... 606 } 607}) 608``` 609 610## print<sup>11+</sup> 611 612print(files: Array<string>, context: Context): Promise<PrintTask> 613 614打印接口,传入文件进行打印,使用Promise异步回调。 615 616**需要权限:** ohos.permission.PRINT 617 618**系统能力:** SystemCapability.Print.PrintFramework 619 620**参数:** 621| **参数名** | **类型** | **必填** | **说明** | 622| -------- | -------- | -------- | -------- | 623| files | Array<string> | 是 | 待打印文件列表,支持图片(.jpg .png .gif .bmp .webp)和pdf。系统应用传入uri时,需先调用uriPermissionManager.grantUriPermission()接口给打印应用授权,此接口为系统接口。三方应用建议使用[print](#print11-2)。 | 624| context | Context | 是 | 用于拉起系统打印界面的UIAbilityContext | 625 626**返回值:** 627| **类型** | **说明** | 628| -------- | -------- | 629| Promise<PrintTask> | 打印完成结果 | 630 631**错误码:** 632 633以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 634 635| 错误码ID | 错误信息 | 636| -------- | ------------------------------------------- | 637| 201 | the application does not have permission to call this function. | 638| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 639 640**示例:** 641 642```ts 643import { print } from '@kit.BasicServicesKit'; 644import { BusinessError } from '@ohos.base'; 645 646//传入文件的uri 647let files = ['file://data/print/a.png', 'file://data/print/b.png']; 648//或者传入fd 649//let files = ['fd://1', 'fd://2']; 650let context = getContext(this); 651print.print(files, context).then((printTask: print.PrintTask) => { 652 printTask.on('succeed', () => { 653 console.log('print state is succeed'); 654 }) 655 // ... 656}).catch((error: BusinessError) => { 657 console.log('print err ' + JSON.stringify(error)); 658}) 659``` 660 661## print<sup>11+</sup> 662 663print(jobName: string, printAdapter: PrintDocumentAdapter, printAttributes: PrintAttributes, context: Context): Promise<PrintTask> 664 665打印接口,传入文件进行打印,三方应用需要更新打印文件,使用Promise异步回调。 666 667**需要权限:** ohos.permission.PRINT 668 669**系统能力:** SystemCapability.Print.PrintFramework 670 671**参数:** 672| **参数名** | **类型** | **必填** | **说明** | 673| -------- | -------- | -------- | -------- | 674| jobName | string | 是 | 表示待打印文件名称,例如:test.pdf。打印侧会通过[onStartLayoutWrite](#onstartlayoutwrite)接口将空的pdf文件的fd传给接口调用方,由调用方使用新的打印参数更新待打印文件。 | 675| printAdapter | PrintDocumentAdapter | 是 | 表示三方应用实现的[PrintDocumentAdapter](#printdocumentadapter11)接口实例 | 676| printAttributes | PrintAttributes | 是 | 表示打印参数 | 677| context | Context | 是 | 用于拉起系统打印界面的UIAbilityContext | 678 679**返回值:** 680| **类型** | **说明** | 681| -------- | -------- | 682| Promise<PrintTask> | 打印完成结果 | 683 684**错误码:** 685 686以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 687 688| 错误码ID | 错误信息 | 689| -------- | ------------------------------------------- | 690| 201 | the application does not have permission to call this function. | 691| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 692 693**示例:** 694 695```ts 696import { print } from '@kit.BasicServicesKit'; 697import { BusinessError } from '@ohos.base'; 698 699let jobName : string = "jobName"; 700let printAdapter : print.PrintDocumentAdapter | null = null; 701let printAttributes : print.PrintAttributes = { 702 copyNumber: 1, 703 pageRange: { 704 startPage: 0, 705 endPage: 5, 706 pages: [] 707 }, 708 pageSize: print.PrintPageType.PAGE_ISO_A3, 709 directionMode: print.PrintDirectionMode.DIRECTION_MODE_AUTO, 710 colorMode: print.PrintColorMode.COLOR_MODE_MONOCHROME, 711 duplexMode: print.PrintDuplexMode.DUPLEX_MODE_NONE 712} 713let context = getContext(); 714 715print.print(jobName, printAdapter, printAttributes, context).then((printTask: print.PrintTask) => { 716 printTask.on('succeed', () => { 717 console.log('print state is succeed'); 718 }) 719 // ... 720}).catch((error: BusinessError) => { 721 console.log('print err ' + JSON.stringify(error)); 722}) 723``` 724 725## PrintAttributes<sup>11+</sup> 726 727定义打印参数的接口。 728 729**系统能力:** SystemCapability.Print.PrintFramework 730 731**属性:** 732| **名称** | **类型** | **必填** | **说明** | 733| -------- | -------- | -------- | -------- | 734| copyNumber | number | 否 | 表示文件打印份数 | 735| pageRange | PrintPageRange | 否 | 表示待打印文件的页面范围 | 736| pageSize | PrintPageSize \| PrintPageType | 否 | 表示代打印文件的纸张类型 | 737| directionMode | PrintDirectionMode | 否 | 表示待打印文件的方向 | 738| colorMode | PrintColorMode | 否 | 表示待打印文件的色彩模式 | 739| duplexMode | PrintDuplexMode | 否 | 表示待打印文件的单双面模式 | 740 741## PrintPageRange<sup>11+</sup> 742 743定义打印范围的接口。 744 745**系统能力:** SystemCapability.Print.PrintFramework 746 747**属性:** 748| **名称** | **类型** | **必填** | **说明** | 749| -------- | -------- | -------- | -------- | 750| startPage | number | 否 | 表示起始页 | 751| endPage | number | 否 | 表示结束页 | 752| pages | Array<number> | 否 | 表示待打印的页面范围的集合| 753 754 755## PrintPageSize<sup>11+</sup> 756 757定义打印页面尺寸的接口。 758 759**系统能力:** SystemCapability.Print.PrintFramework 760 761**属性:** 762| **名称** | **类型** | **必填** | **说明** | 763| -------- | -------- | -------- | -------- | 764| id | string | 是 | 表示纸张类型ID | 765| name | string | 是 | 表示纸张类型名称 | 766| width | number | 是 | 表示页面宽度,单位:毫米 | 767| height | number | 是 | 表示页面高度,单位:毫米 | 768 769 770 771## PrintDirectionMode<sup>11+</sup> 772 773打印纸张方向的枚举。 774 775**系统能力:** SystemCapability.Print.PrintFramework 776 777| **名称** | **值** | **说明** | 778| -------- | -------- | -------- | 779| DIRECTION_MODE_AUTO | 0 | 表示自动选择纸张方向 | 780| DIRECTION_MODE_PORTRAIT | 1 | 表示纵向打印 | 781| DIRECTION_MODE_LANDSCAPE | 2 | 表示横向打印 | 782 783## PrintColorMode<sup>11+</sup> 784 785打印色彩模式的枚举。 786 787**系统能力:** SystemCapability.Print.PrintFramework 788 789| **名称** | **值** | **说明** | 790| -------- | -------- | -------- | 791| COLOR_MODE_MONOCHROME | 0 | 表示黑白打印 | 792| COLOR_MODE_COLOR | 1 | 表示彩色打印 | 793 794## PrintDuplexMode<sup>11+</sup> 795 796打印单双面模式的枚举。 797 798**系统能力:** SystemCapability.Print.PrintFramework 799 800| **名称** | **值** | **说明** | 801| -------- | -------- | -------- | 802| DUPLEX_MODE_NONE | 0 | 表示单面打印 | 803| DUPLEX_MODE_LONG_EDGE | 1 | 表示双面打印沿长边翻转 | 804| DUPLEX_MODE_SHORT_EDGE | 2 | 表示双面打印沿短边翻转 | 805 806## PrintPageType<sup>11+</sup> 807 808打印纸张类型的枚举。 809 810**系统能力:** SystemCapability.Print.PrintFramework 811 812| **名称** | **值** | **说明** | 813| -------- | -------- | -------- | 814| PAGE_ISO_A3 | 0 | 表示A3 | 815| PAGE_ISO_A4 | 1 | 表示A4 | 816| PAGE_ISO_A5 | 2 | 表示A5 | 817| PAGE_JIS_B5 | 3 | 表示B5 | 818| PAGE_ISO_C5 | 4 | 表示C5 | 819| PAGE_ISO_DL | 5 | 表示DL | 820| PAGE_LETTER | 6 | 表示Letter | 821| PAGE_LEGAL | 7 | 表示Legal | 822| PAGE_PHOTO_4X6 | 8 | 表示4x6相纸 | 823| PAGE_PHOTO_5X7 | 9 | 表示5x7相纸 | 824| PAGE_INT_DL_ENVELOPE | 10 | 表示INT DL ENVELOPE | 825| PAGE_B_TABLOID | 11 | 表示B Tabloid | 826 827## PrintDocumentAdapterState<sup>11+</sup> 828 829打印任务状态的枚举。 830 831**系统能力:** SystemCapability.Print.PrintFramework 832 833| **名称** | **值** | **说明** | 834| -------- | -------- | -------- | 835| PREVIEW_DESTROY | 0 | 表示预览失败 | 836| PRINT_TASK_SUCCEED | 1 | 表示打印任务成功 | 837| PRINT_TASK_FAIL | 2 | 表示打印任务失败 | 838| PRINT_TASK_CANCEL | 3 | 表示打印任务取消 | 839| PRINT_TASK_BLOCK | 4 | 表示打印任务阻塞 | 840 841## PrintFileCreationState<sup>11+</sup> 842 843打印文件创建状态的枚举。 844 845**系统能力:** SystemCapability.Print.PrintFramework 846 847| **名称** | **值** | **说明** | 848| -------- | -------- | -------- | 849| PRINT_FILE_CREATED | 0 | 表示打印文件创建成功 | 850| PRINT_FILE_CREATION_FAILED | 1 | 表示打印文件创建失败| 851| PRINT_FILE_CREATED_UNRENDERED | 2 | 表示打印文件创建成功但未渲染 | 852 853## PrinterState<sup>14+</sup> 854 855打印机状态的枚举。 856 857**系统能力:** SystemCapability.Print.PrintFramework 858 859| **名称** | **值** | **说明** | 860| -------- | -------- | -------- | 861| PRINTER_ADDED | 0 | 表示新打印机到达 | 862| PRINTER_REMOVED | 1 | 表示打印机丢失 | 863| PRINTER_CAPABILITY_UPDATED | 2 | 表示打印机更新 | 864| PRINTER_CONNECTED | 3 | 表示打印机已连接 | 865| PRINTER_DISCONNECTED | 4 | 表示打印机已断开连接 | 866| PRINTER_RUNNING | 5 | 表示打印机正在运行 | 867 868## PrintJobState<sup>14+</sup> 869 870打印任务状态的枚举。 871 872**系统能力:** SystemCapability.Print.PrintFramework 873 874| **名称** | **值** | **说明** | 875| -------- | -------- | -------- | 876| PRINT_JOB_PREPARE | 0 | 表示打印任务的初始状态 | 877| PRINT_JOB_QUEUED | 1 | 表示打印任务传送到打印机 | 878| PRINT_JOB_RUNNING | 2 | 表示执行打印任务| 879| PRINT_JOB_BLOCKED | 3 | 表示打印任务已被阻止 | 880| PRINT_JOB_COMPLETED | 4 | 表示打印任务完成 | 881 882## PrintJobSubState<sup>14+</sup> 883 884打印任务子状态的枚举。 885 886**系统能力:** SystemCapability.Print.PrintFramework 887 888| **名称** | **值** | **说明** | 889| -------- | -------- | -------- | 890| PRINT_JOB_COMPLETED_SUCCESS | 0 | 表示打印任务成功 | 891| PRINT_JOB_COMPLETED_FAILED | 1 | 表示打印任务失败 | 892| PRINT_JOB_COMPLETED_CANCELLED | 2 | 表示打印任务已取消| 893| PRINT_JOB_COMPLETED_FILE_CORRUPTED | 3 | 表示打印任务已损坏 | 894| PRINT_JOB_BLOCK_OFFLINE | 4 | 表示打印处于离线状态 | 895| PRINT_JOB_BLOCK_BUSY | 5 | 表示打印被其他进程占用 | 896| PRINT_JOB_BLOCK_CANCELLED | 6 | 表示打印任务已取消 | 897| PRINT_JOB_BLOCK_OUT_OF_PAPER | 7 | 表示打印纸张用完 | 898| PRINT_JOB_BLOCK_OUT_OF_INK | 8 | 表示打印墨水用完 | 899| PRINT_JOB_BLOCK_OUT_OF_TONER | 9 | 表示打印墨粉用完 | 900| PRINT_JOB_BLOCK_JAMMED | 10 | 表示打印卡纸 | 901| PRINT_JOB_BLOCK_DOOR_OPEN | 11 | 表示打印盖开启 | 902| PRINT_JOB_BLOCK_SERVICE_REQUEST | 12 | 表示打印服务请求 | 903| PRINT_JOB_BLOCK_LOW_ON_INK | 13 | 表示打印墨水不足 | 904| PRINT_JOB_BLOCK_LOW_ON_TONER | 14 | 表示打印墨粉不足 | 905| PRINT_JOB_BLOCK_REALLY_LOW_ON_INK | 15 | 表示打印墨水量非常低 | 906| PRINT_JOB_BLOCK_BAD_CERTIFICATE | 16 | 表示打印证书有误 | 907| PRINT_JOB_BLOCK_ACCOUNT_ERROR | 18 | 表示打印账户时出错 | 908| PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR | 19 | 表示打印许可异常 | 909| PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR | 20 | 表示彩色打印权限异常 | 910| PRINT_JOB_BLOCK_NETWORK_ERROR | 21 | 表示设备未连接到网络 | 911| PRINT_JOB_BLOCK_SERVER_CONNECTION_ERROR | 22 | 表示无法连接服务器 | 912| PRINT_JOB_BLOCK_LARGE_FILE_ERROR | 23 | 表示打印大文件异常 | 913| PRINT_JOB_BLOCK_FILE_PARSING_ERROR | 24 | 表示文件分析异常 | 914| PRINT_JOB_BLOCK_SLOW_FILE_CONVERSION | 25 | 表示文件转换太慢 | 915| PRINT_JOB_RUNNING_UPLOADING_FILES | 26 | 表示正在上传文件 | 916| PRINT_JOB_RUNNING_CONVERTING_FILES | 27 | 表示正在转换文件 | 917| PRINT_JOB_BLOCK_UNKNOWN | 99 | 表示打印未知问题 | 918 919## PrintErrorCode<sup>14+</sup> 920 921打印错误代码的枚举。 922 923**系统能力:** SystemCapability.Print.PrintFramework 924 925| **名称** | **值** | **说明** | 926| -------- | -------- | -------- | 927| E_PRINT_NONE | 0 | 表示没有错误 | 928| E_PRINT_NO_PERMISSION | 201 | 表示没有许可 | 929| E_PRINT_INVALID_PARAMETER | 401 | 表示无效的参数 | 930| E_PRINT_GENERIC_FAILURE | 13100001 | 表示一般打印失败 | 931| E_PRINT_RPC_FAILURE | 13100002 | 表示RPC失败 | 932| E_PRINT_SERVER_FAILURE | 13100003 | 表示打印服务失败 | 933| E_PRINT_INVALID_EXTENSION | 13100004 | 表示打印扩展无效 | 934| E_PRINT_INVALID_PRINTER | 13100005 | 表示打印机无效 | 935| E_PRINT_INVALID_PRINT_JOB | 13100006 | 表示打印任务无效 | 936| E_PRINT_FILE_IO | 13100007 | 表示文件输入/输出错误 | 937 938## ApplicationEvent<sup>14+</sup> 939 940打印应用事件的枚举。 941 942**系统能力:** SystemCapability.Print.PrintFramework 943 944| **名称** | **值** | **说明** | 945| -------- | -------- | -------- | 946| APPLICATION_CREATED | 0 | 表示打印应用被拉起的事件 | 947| APPLICATION_CLOSED_FOR_STARTED | 1 | 表示由于点击打印而关于打印应用的事件 | 948| APPLICATION_CLOSED_FOR_CANCELED | 2 | 表示由于点击取消而关闭打印应用的事件 | 949 950## addPrinterToDiscovery<sup>14+</sup> 951 952addPrinterToDiscovery(printerInformation: PrinterInformation): Promise<void> 953 954添加打印机到系统打印机发现列表,使用Promise异步回调。 955 956**需要权限:** ohos.permission.PRINT 957 958**系统能力:** SystemCapability.Print.PrintFramework 959 960**参数:** 961| **参数名** | **类型** | **必填** | **说明** | 962| -------- | -------- | -------- | -------- | 963| printerInformation | PrinterInformation | 是 | 表示新发现的打印机 | 964 965**返回值:** 966| **类型** | **说明** | 967| -------- | -------- | 968| Promise<void> | 添加打印机到系统打印机发现列表完成结果 | 969 970**错误码:** 971 972以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 973 974| 错误码ID | 错误信息 | 975| -------- | ------------------------------------------- | 976| 201 | the application does not have permission to call this function. | 977| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 978 979**示例:** 980 981```ts 982import { print } from '@kit.BasicServicesKit'; 983import { BusinessError } from '@ohos.base'; 984 985let printerInformation : print.PrinterInformation = { 986 printerId : 'testPrinterId', 987 printerName : 'testPrinterName', 988 printerStatus : 0, 989 description : 'testDesc', 990 uri : 'testUri', 991 printerMake : 'testPrinterMake', 992 options : 'testOps' 993}; 994print.addPrinterToDiscovery(printerInformation).then((data : void) => { 995 console.log('addPrinterToDiscovery data : ' + JSON.stringify(data)); 996}).catch((error: BusinessError) => { 997 console.log('addPrinterToDiscovery error : ' + JSON.stringify(error)); 998}) 999``` 1000 1001## updatePrinterInDiscovery<sup>14+</sup> 1002 1003updatePrinterInDiscovery(printerInformation: PrinterInformation): Promise<void> 1004 1005更新打印机能力到系统打印机发现列表,使用Promise异步回调。 1006 1007**需要权限:** ohos.permission.PRINT 1008 1009**系统能力:** SystemCapability.Print.PrintFramework 1010 1011**参数:** 1012| **参数名** | **类型** | **必填** | **说明** | 1013| -------- | -------- | -------- | -------- | 1014| printerInformation | PrinterInformation | 是 | 表示待更新能力的打印机 | 1015 1016**返回值:** 1017| **类型** | **说明** | 1018| -------- | -------- | 1019| Promise<void> | 更新打印机能力到系统打印机发现列表完成结果 | 1020 1021**错误码:** 1022 1023以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 1024 1025| 错误码ID | 错误信息 | 1026| -------- | ------------------------------------------- | 1027| 201 | the application does not have permission to call this function. | 1028| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 1029 1030**示例:** 1031 1032```ts 1033import { print } from '@kit.BasicServicesKit'; 1034import { BusinessError } from '@ohos.base'; 1035 1036let testPageSize : print.PrintPageSize = { 1037 id : 'ISO_A4', 1038 name : 'iso_a4_210x297mm', 1039 width : 8268, 1040 height : 11692 1041}; 1042 1043let testCapability : print.PrinterCapabilities = { 1044 supportedPageSizes : [testPageSize], 1045 supportedColorModes : [print.PrintColorMode.COLOR_MODE_MONOCHROME], 1046 supportedDuplexModes : [print.PrintDuplexMode.DUPLEX_MODE_NONE], 1047 supportedMediaTypes : ['stationery'], 1048 supportedQualities : [print.PrintQuality.QUALITY_NORMAL], 1049 supportedOrientations : [print.PrintOrientationMode.ORIENTATION_MODE_PORTRAIT], 1050 options : 'testOptions' 1051}; 1052 1053let printerInformation : print.PrinterInformation = { 1054 printerId : 'testPrinterId', 1055 printerName : 'testPrinterName', 1056 printerStatus : 0, 1057 description : 'testDesc', 1058 capability : testCapability, 1059 uri : 'testUri', 1060 printerMake : 'testPrinterMake', 1061 options : 'testOptions' 1062}; 1063print.updatePrinterInDiscovery(printerInformation).then((data : void) => { 1064 console.log('updatePrinterInDiscovery data : ' + JSON.stringify(data)); 1065}).catch((error: BusinessError) => { 1066 console.log('updatePrinterInDiscovery error : ' + JSON.stringify(error)); 1067}) 1068``` 1069 1070## removePrinterFromDiscovery<sup>14+</sup> 1071 1072removePrinterFromDiscovery(printerId: string): Promise<void> 1073 1074从系统打印机发现列表里移除打印机,使用Promise异步回调。 1075 1076**需要权限:** ohos.permission.PRINT 1077 1078**系统能力:** SystemCapability.Print.PrintFramework 1079 1080**参数:** 1081| **参数名** | **类型** | **必填** | **说明** | 1082| -------- | -------- | -------- | -------- | 1083| printerId | string | 是 | 表示待移除的打印机 | 1084 1085**返回值:** 1086| **类型** | **说明** | 1087| -------- | -------- | 1088| Promise<void> | 从系统打印机发现列表里移除打印机完成结果 | 1089 1090**错误码:** 1091 1092以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 1093 1094| 错误码ID | 错误信息 | 1095| -------- | ------------------------------------------- | 1096| 201 | the application does not have permission to call this function. | 1097| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 1098 1099**示例:** 1100 1101```ts 1102import { print } from '@kit.BasicServicesKit'; 1103import { BusinessError } from '@ohos.base'; 1104 1105let printerId : string = 'testPrinterId'; 1106print.removePrinterFromDiscovery(printerId).then((data : void) => { 1107 console.log('removePrinterFromDiscovery data : ' + JSON.stringify(data)); 1108}).catch((error: BusinessError) => { 1109 console.log('removePrinterFromDiscovery error : ' + JSON.stringify(error)); 1110}) 1111``` 1112 1113## getPrinterInformationById<sup>14+</sup> 1114 1115getPrinterInformationById(printerId: string): Promise<PrinterInformation> 1116 1117根据打印机id获取打印机信息,使用Promise异步回调。 1118 1119**需要权限:** ohos.permission.PRINT 1120 1121**系统能力:** SystemCapability.Print.PrintFramework 1122 1123**参数:** 1124| **参数名** | **类型** | **必填** | **说明** | 1125| -------- | -------- | -------- | -------- | 1126| printerId | string | 是 | 表示待获取信息的打印机id | 1127 1128**返回值:** 1129| **类型** | **说明** | 1130| -------- | -------- | 1131| Promise<PrinterInformation> | 根据打印机id获取的对应打印机信息 | 1132 1133**错误码:** 1134 1135以下错误码的详细介绍请参见[打印服务错误码](./errorcode-print.md)。 1136 1137| 错误码ID | 错误信息 | 1138| -------- | ------------------------------------------- | 1139| 201 | the application does not have permission to call this function. | 1140| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 1141 1142**示例:** 1143 1144```ts 1145import { print } from '@kit.BasicServicesKit'; 1146import { BusinessError } from '@ohos.base'; 1147 1148let printerId : string = 'testPrinterId'; 1149print.getPrinterInformationById(printerId).then((printerInformation : print.PrinterInformation) => { 1150 console.log('getPrinterInformationById data : ' + JSON.stringify(printerInformation)); 1151}).catch((error: BusinessError) => { 1152 console.log('getPrinterInformationById error : ' + JSON.stringify(error)); 1153}) 1154``` 1155 1156## PrinterInformation<sup>14+</sup> 1157 1158定义打印机信息的接口。 1159 1160**系统能力:** SystemCapability.Print.PrintFramework 1161 1162**属性:** 1163| **名称** | **类型** | **必填** | **说明** | 1164| -------- | -------- | -------- | -------- | 1165| printerId | string | 是 | 表示打印机ID | 1166| printerName | string | 是 | 表示打印机名称 | 1167| printerStatus | PrinterStatus | 是 | 表示当前打印机状态 | 1168| description | string | 否 | 表示打印机说明 | 1169| capability | PrinterCapabilities | 否 | 表示打印机能力 | 1170| uri | string | 否 | 表示打印机uri | 1171| printerMake | string | 否 | 表示打印机型号 | 1172| options | string | 否 | 表示打印机详细信息 | 1173 1174## PrinterCapabilities<sup>14+</sup> 1175 1176定义打印机能力的接口。 1177 1178**系统能力:** SystemCapability.Print.PrintFramework 1179 1180**属性:** 1181| **名称** | **类型** | **必填** | **说明** | 1182| -------- | -------- | -------- | -------- | 1183| supportedPageSizes | Array<PrintPageSize> | 是 | 表示打印机支持的纸张尺寸列表 | 1184| supportedColorModes | Array<PrintColorMode> | 是 | 表示打印机支持的色彩模式列表 | 1185| supportedDuplexModes | Array<PrintDuplexMode> | 是 | 表示打印机支持的单双面模式列表 | 1186| supportedMediaTypes | Array<string> | 否 | 表示打印机支持的纸张类型列表 | 1187| supportedQualities | Array<PrintQuality> | 否 | 表示打印机支持的打印质量列表 | 1188| supportedOrientations | Array<PrintOrientationMode> | 否 | 表示打印机支持的打印方向列表 | 1189| options | string | 否 | 表示打印机能力详细信息 | 1190 1191## PrintQuality<sup>14+</sup> 1192 1193打印质量的枚举。 1194 1195**系统能力:** SystemCapability.Print.PrintFramework 1196 1197| **名称** | **值** | **说明** | 1198| -------- | -------- | -------- | 1199| QUALITY_DRAFT | 3 | 表示经济的打印质量 | 1200| QUALITY_NORMAL | 4 | 表示标准的打印质量 | 1201| QUALITY_HIGH | 5 | 表示最佳的打印质量 | 1202 1203## PrintOrientationMode<sup>14+</sup> 1204 1205打印方向的枚举。 1206 1207**系统能力:** SystemCapability.Print.PrintFramework 1208 1209| **名称** | **值** | **说明** | 1210| -------- | -------- | -------- | 1211| ORIENTATION_MODE_PORTRAIT | 0 | 表示横向打印 | 1212| ORIENTATION_MODE_LANDSCAPE | 1 | 表示纵向打印 | 1213| ORIENTATION_MODE_REVERSE_LANDSCAPE | 2 | 表示纵向翻转打印 | 1214| ORIENTATION_MODE_REVERSE_PORTRAIT | 3 | 表示横向翻转打印 | 1215| ORIENTATION_MODE_NONE | 4 | 表示自适应方向打印 | 1216 1217## PrinterStatus<sup>14+</sup> 1218 1219打印机状态的枚举。 1220 1221**系统能力:** SystemCapability.Print.PrintFramework 1222 1223| **名称** | **值** | **说明** | 1224| -------- | -------- | -------- | 1225| PRINTER_IDLE | 0 | 表示打印机空闲状态 | 1226| PRINTER_BUSY | 1 | 表示打印机忙碌状态 | 1227| PRINTER_UNAVAILABLE | 2 | 表示打印机脱机状态 | 1228