1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type Context from './application/Context'; 23 24/** 25 * System print 26 * 27 * @namespace print 28 * @syscap SystemCapability.Print.PrintFramework 29 * @since 10 30 */ 31declare namespace print { 32 33 /** 34 * PrintTask provide event callback. 35 * @interface PrintTask 36 * @syscap SystemCapability.Print.PrintFramework 37 * @since 10 38 */ 39 interface PrintTask { 40 /** 41 * Register event callback when the current print task is in process. 42 * @permission ohos.permission.PRINT 43 * @param { 'block' } type - Indicates the print task has been blocked. 44 * @param { Callback<void> } callback - The callback function for print task change event 45 * @throws { BusinessError } 201 - the application does not have permission to call this function. 46 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 47 * @syscap SystemCapability.Print.PrintFramework 48 * @since 10 49 */ 50 on(type: 'block', callback: Callback<void>): void; 51 52 /** 53 * Register event callback when the current print task is in process. 54 * @permission ohos.permission.PRINT 55 * @param { 'succeed' } type - Indicates the print task succeed. 56 * @param { Callback<void> } callback - The callback function for print task change event 57 * @throws { BusinessError } 201 - the application does not have permission to call this function. 58 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 59 * @syscap SystemCapability.Print.PrintFramework 60 * @since 10 61 */ 62 on(type: 'succeed', callback: Callback<void>): void; 63 64 /** 65 * Register event callback when the current print task is in process. 66 * @permission ohos.permission.PRINT 67 * @param { 'fail' } type - Indicates the print task has completed with failure. 68 * @param { Callback<void> } callback - The callback function for print task change event 69 * @throws { BusinessError } 201 - the application does not have permission to call this function. 70 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 71 * @syscap SystemCapability.Print.PrintFramework 72 * @since 10 73 */ 74 on(type: 'fail', callback: Callback<void>): void; 75 76 /** 77 * Register event callback when the current print task is in process. 78 * @permission ohos.permission.PRINT 79 * @param { 'cancel' } type - Indicates the print task has been cancelled. 80 * @param { Callback<void> } callback - The callback function for print task change event 81 * @throws { BusinessError } 201 - the application does not have permission to call this function. 82 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 83 * @syscap SystemCapability.Print.PrintFramework 84 * @since 10 85 */ 86 on(type: 'cancel', callback: Callback<void>): void; 87 88 /** 89 * Unregister event callback when the current print task is in process. 90 * @permission ohos.permission.PRINT 91 * @param { 'block' } type - Indicates the print task has been blocked. 92 * @param { Callback<void> } callback - The callback function for print task change event 93 * @throws { BusinessError } 201 - the application does not have permission to call this function. 94 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 95 * @syscap SystemCapability.Print.PrintFramework 96 * @since 10 97 */ 98 off(type: 'block', callback?: Callback<void>): void; 99 100 /** 101 * Unregister event callback when the current print task is in process. 102 * @permission ohos.permission.PRINT 103 * @param { 'succeed' } type - Indicates the print task succeed. 104 * @param { Callback<void> } callback - The callback function for print task change event 105 * @throws { BusinessError } 201 - the application does not have permission to call this function. 106 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 107 * @syscap SystemCapability.Print.PrintFramework 108 * @since 10 109 */ 110 off(type: 'succeed', callback?: Callback<void>): void; 111 112 /** 113 * Unregister event callback when the current print task is in process. 114 * @permission ohos.permission.PRINT 115 * @param { 'fail' } type - Indicates the print task has completed with failure. 116 * @param { Callback<void> } callback - The callback function for print task change event 117 * @throws { BusinessError } 201 - the application does not have permission to call this function. 118 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 119 * @syscap SystemCapability.Print.PrintFramework 120 * @since 10 121 */ 122 off(type: 'fail', callback?: Callback<void>): void; 123 124 /** 125 * Unregister event callback when the current print task is in process. 126 * @permission ohos.permission.PRINT 127 * @param { 'cancel' } type - Indicates the print task has been cancelled. 128 * @param { Callback<void> } callback - The callback function for print task change event 129 * @throws { BusinessError } 201 - the application does not have permission to call this function. 130 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 131 * @syscap SystemCapability.Print.PrintFramework 132 * @since 10 133 */ 134 off(type: 'cancel', callback?: Callback<void>): void; 135 } 136 137 /** 138 * Third-party application implement this interface to render files to be printed. 139 * @interface PrintDocumentAdapter 140 * @syscap SystemCapability.Print.PrintFramework 141 * @since 11 142 */ 143 interface PrintDocumentAdapter { 144 145 /** 146 * Implement this function to update the print file. 147 * @permission ohos.permission.PRINT 148 * @param { string } jobId - Indicates print job id. 149 * @param { PrintAttributes } oldAttrs - Indicates old print attributes. 150 * @param { PrintAttributes } newAttrs - Indicates new print attributes. 151 * @param { number } fd - Indicates print file fd. 152 * @param { function } writeResultCallback - Indicates this function should execute after the file is updated. 153 * @throws { BusinessError } 201 - the application does not have permission to call this function. 154 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 155 * @syscap SystemCapability.Print.PrintFramework 156 * @since 11 157 */ 158 onStartLayoutWrite(jobId: string, oldAttrs: PrintAttributes, newAttrs: PrintAttributes, fd: number, 159 writeResultCallback: (jobId: string, writeResult: PrintFileCreationState) => void): void; 160 161 /** 162 * Implement this function to listen job status change. 163 * @permission ohos.permission.PRINT 164 * @param { string } jobId - Indicates print job id. 165 * @param { PrintDocumentAdapterState } state - Indicates job changes to this state. 166 * @throws { BusinessError } 201 - the application does not have permission to call this function. 167 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 168 * @syscap SystemCapability.Print.PrintFramework 169 * @since 11 170 */ 171 onJobStateChanged(jobId: string, state: PrintDocumentAdapterState): void; 172 } 173 174 /** 175 * Start new print task for App. 176 * @permission ohos.permission.PRINT 177 * @param { Array<string> } files - Indicates the filepath list to be printed. Only pdf and picture filetype are supported. 178 * @param { AsyncCallback<PrintTask> } callback - The callback function for print task. 179 * @throws { BusinessError } 201 - the application does not have permission to call this function. 180 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 181 * @syscap SystemCapability.Print.PrintFramework 182 * @since 10 183 */ 184 function print(files: Array<string>, callback: AsyncCallback<PrintTask>): void; 185 186 /** 187 * Start new print task for App. 188 * @permission ohos.permission.PRINT 189 * @param { Array<string> } files - Indicates the filepath list to be printed. Only pdf and picture filetype are supported. 190 * @returns { Promise<PrintTask> } the promise returned by the function. 191 * @throws { BusinessError } 201 - the application does not have permission to call this function. 192 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 193 * @syscap SystemCapability.Print.PrintFramework 194 * @since 10 195 */ 196 function print(files: Array<string>): Promise<PrintTask>; 197 198 /** 199 * Start new print task for App. 200 * @permission ohos.permission.PRINT 201 * @param { Array<string> } files - Indicates the filepath list to be printed. Only pdf and picture filetype are supported. 202 * @param { Context } context - The ability context that initiates the call print request. 203 * @param { AsyncCallback<PrintTask> } callback - The callback function for print task. 204 * @throws { BusinessError } 201 - the application does not have permission to call this function. 205 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 206 * @syscap SystemCapability.Print.PrintFramework 207 * @since 11 208 */ 209 function print(files: Array<string>, context: Context, callback: AsyncCallback<PrintTask>): void; 210 211 /** 212 * Start new print task for App. 213 * @permission ohos.permission.PRINT 214 * @param { Array<string> } files - Indicates the filepath list to be printed. Only pdf and picture filetype are supported. 215 * @param { Context } context - The ability context that initiates the call print request. 216 * @returns { Promise<PrintTask> } the promise returned by the function. 217 * @throws { BusinessError } 201 - the application does not have permission to call this function. 218 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 219 * @syscap SystemCapability.Print.PrintFramework 220 * @since 11 221 */ 222 function print(files: Array<string>, context: Context): Promise<PrintTask>; 223 224 /** 225 * Start new print task for App And the App need update print file. 226 * @permission ohos.permission.PRINT 227 * @param { string } jobName - Indicates print file Name. 228 * @param { PrintDocumentAdapter } printAdapter - Indicates functions implemented by the cpp. 229 * @param { PrintAttributes } printAttributes - Indicates print attributes. 230 * @param { Context } context - The ability context that initiates the call print request. 231 * @returns { Promise<PrintTask> } the promise returned by the function. 232 * @throws { BusinessError } 201 - the application does not have permission to call this function. 233 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 234 * @syscap SystemCapability.Print.PrintFramework 235 * @since 11 236 */ 237 function print(jobName: string, printAdapter: PrintDocumentAdapter, printAttributes: PrintAttributes, 238 context: Context): Promise<PrintTask>; 239 240 /** 241 * defines print attributes. 242 * @typedef PrintAttributes 243 * @syscap SystemCapability.Print.PrintFramework 244 * @since 11 245 */ 246 interface PrintAttributes { 247 /** 248 * Copies of document list. 249 * @type { ?number } 250 * @syscap SystemCapability.Print.PrintFramework 251 * @since 11 252 */ 253 copyNumber?: number; 254 255 /** 256 * Range size to be printed. 257 * @type { ?PrintPageRange } 258 * @syscap SystemCapability.Print.PrintFramework 259 * @since 11 260 */ 261 pageRange?: PrintPageRange; 262 263 /** 264 * Page size. 265 * @type { ?(PrintPageSize | PrintPageType) } 266 * @syscap SystemCapability.Print.PrintFramework 267 * @since 11 268 */ 269 pageSize?: PrintPageSize | PrintPageType; 270 271 /** 272 * Print direction. 273 * @type { ?PrintDirectionMode } 274 * @syscap SystemCapability.Print.PrintFramework 275 * @since 11 276 */ 277 directionMode?: PrintDirectionMode; 278 279 /** 280 * Color mode. 281 * @type { ?PrintColorMode } 282 * @syscap SystemCapability.Print.PrintFramework 283 * @since 11 284 */ 285 colorMode?: PrintColorMode; 286 287 /** 288 * Duplex mode. 289 * @type { ?PrintDuplexMode } 290 * @syscap SystemCapability.Print.PrintFramework 291 * @since 11 292 */ 293 duplexMode?: PrintDuplexMode; 294 } 295 296 /** 297 * defines print page range. 298 * @typedef PrintPageRange 299 * @syscap SystemCapability.Print.PrintFramework 300 * @since 11 301 */ 302 interface PrintPageRange { 303 /** 304 * Start page of sequence. 305 * @type { ?number } 306 * @syscap SystemCapability.Print.PrintFramework 307 * @since 11 308 */ 309 startPage?: number; 310 311 /** 312 * End page of sequence. 313 * @type { ?number } 314 * @syscap SystemCapability.Print.PrintFramework 315 * @since 11 316 */ 317 endPage?: number; 318 319 /** 320 * Discrete page of sequence. 321 * @type { ?Array<number> } 322 * @syscap SystemCapability.Print.PrintFramework 323 * @since 11 324 */ 325 pages?: Array<number>; 326 } 327 328 /** 329 * defines print margin. 330 * @typedef PrintMargin 331 * @syscap SystemCapability.Print.PrintFramework 332 * @systemapi Hide this for inner system use. 333 * @since 10 334 */ 335 interface PrintMargin { 336 /** 337 * Top margin. 338 * @type { ?number } 339 * @syscap SystemCapability.Print.PrintFramework 340 * @systemapi 341 * @since 10 342 */ 343 top?: number; 344 345 /** 346 * Bottom margin. 347 * @type { ?number } 348 * @syscap SystemCapability.Print.PrintFramework 349 * @systemapi 350 * @since 10 351 */ 352 bottom?: number; 353 354 /** 355 * Left margin. 356 * @type { ?number } 357 * @syscap SystemCapability.Print.PrintFramework 358 * @systemapi 359 * @since 10 360 */ 361 left?: number; 362 363 /** 364 * Right margin. 365 * @type { ?number } 366 * @syscap SystemCapability.Print.PrintFramework 367 * @systemapi 368 * @since 10 369 */ 370 right?: number; 371 } 372 373 /** 374 * defines print range. 375 * @typedef PrinterRange 376 * @syscap SystemCapability.Print.PrintFramework 377 * @systemapi Hide this for inner system use. 378 * @since 10 379 */ 380 interface PrinterRange { 381 /** 382 * Start page of sequence. 383 * @type { ?number } 384 * @syscap SystemCapability.Print.PrintFramework 385 * @systemapi 386 * @since 10 387 */ 388 startPage?: number; 389 390 /** 391 * End page of sequence. 392 * @type { ?number } 393 * @syscap SystemCapability.Print.PrintFramework 394 * @systemapi 395 * @since 10 396 */ 397 endPage?: number; 398 399 /** 400 * Discrete page of sequence. 401 * @type { ?Array<number> } 402 * @syscap SystemCapability.Print.PrintFramework 403 * @systemapi 404 * @since 10 405 */ 406 pages?: Array<number>; 407 } 408 409 /** 410 * defines print preview attribute. 411 * @typedef PreviewAttribute 412 * @syscap SystemCapability.Print.PrintFramework 413 * @systemapi Hide this for inner system use. 414 * @since 10 415 */ 416 interface PreviewAttribute { 417 /** 418 * Preview page range. 419 * @type { PrinterRange } 420 * @syscap SystemCapability.Print.PrintFramework 421 * @systemapi 422 * @since 10 423 */ 424 previewRange: PrinterRange; 425 426 /** 427 * Preview file result. 428 * @type { ?number } 429 * @syscap SystemCapability.Print.PrintFramework 430 * @systemapi 431 * @since 10 432 */ 433 result?: number; 434 } 435 436 /** 437 * defines print resolution. 438 * @typedef PrintResolution 439 * @syscap SystemCapability.Print.PrintFramework 440 * @systemapi Hide this for inner system use. 441 * @since 10 442 */ 443 interface PrintResolution { 444 /** 445 * Resolution id. 446 * @type { string } 447 * @syscap SystemCapability.Print.PrintFramework 448 * @systemapi 449 * @since 10 450 */ 451 id: string; 452 453 /** 454 * Horizontal DPI. 455 * @type { number } 456 * @syscap SystemCapability.Print.PrintFramework 457 * @systemapi 458 * @since 10 459 */ 460 horizontalDpi: number; 461 462 /** 463 * Vertical DPI. 464 * @type { number } 465 * @syscap SystemCapability.Print.PrintFramework 466 * @systemapi 467 * @since 10 468 */ 469 verticalDpi: number; 470 } 471 472 /** 473 * defines print page size. 474 * @typedef PrintPageSize 475 * @syscap SystemCapability.Print.PrintFramework 476 * @since 11 477 */ 478 interface PrintPageSize { 479 /** 480 * Page size id. 481 * @type { string } 482 * @syscap SystemCapability.Print.PrintFramework 483 * @since 11 484 */ 485 id: string; 486 487 /** 488 * Page size name. 489 * @type { string } 490 * @syscap SystemCapability.Print.PrintFramework 491 * @since 11 492 */ 493 name: string; 494 495 /** 496 * Unit: millimeter width. 497 * @type { number } 498 * @syscap SystemCapability.Print.PrintFramework 499 * @since 11 500 */ 501 width: number; 502 503 /** 504 * Unit: millimeter height. 505 * @type { number } 506 * @syscap SystemCapability.Print.PrintFramework 507 * @since 11 508 */ 509 height: number; 510 } 511 512 /** 513 * defines print capability. 514 * @typedef PrinterCapability 515 * @syscap SystemCapability.Print.PrintFramework 516 * @systemapi Hide this for inner system use. 517 * @since 10 518 */ 519 interface PrinterCapability { 520 /** 521 * Color mode. 522 * @type { number } 523 * @syscap SystemCapability.Print.PrintFramework 524 * @systemapi 525 * @since 10 526 */ 527 colorMode: number; 528 529 /** 530 * Duplex mode. 531 * @type { number } 532 * @syscap SystemCapability.Print.PrintFramework 533 * @systemapi 534 * @since 10 535 */ 536 duplexMode: number; 537 538 /** 539 * The page size list supported by the printer. 540 * @type { Array<PrintPageSize> } 541 * @syscap SystemCapability.Print.PrintFramework 542 * @systemapi 543 * @since 10 544 */ 545 pageSize: Array<PrintPageSize>; 546 547 /** 548 * The resolution list supported by the printer. 549 * @type { ?Array<PrintResolution> } 550 * @syscap SystemCapability.Print.PrintFramework 551 * @systemapi 552 * @since 10 553 */ 554 resolution?: Array<PrintResolution>; 555 556 /** 557 * Min margin of printer. 558 * @type { ?PrintMargin } 559 * @syscap SystemCapability.Print.PrintFramework 560 * @systemapi 561 * @since 10 562 */ 563 minMargin?: PrintMargin; 564 565 /** 566 * JSON object string. 567 * @type { ?Object } 568 * @syscap SystemCapability.Print.PrintFramework 569 * @systemapi 570 * @since 11 571 */ 572 options?: Object; 573 } 574 575 /** 576 * defines print info. 577 * @typedef PrinterInfo 578 * @syscap SystemCapability.Print.PrintFramework 579 * @systemapi Hide this for inner system use. 580 * @since 10 581 */ 582 interface PrinterInfo { 583 /** 584 * Printer id. 585 * @type { string } 586 * @syscap SystemCapability.Print.PrintFramework 587 * @systemapi 588 * @since 10 589 */ 590 printerId: string; 591 592 /** 593 * Printer name. 594 * @type { string } 595 * @syscap SystemCapability.Print.PrintFramework 596 * @systemapi 597 * @since 10 598 */ 599 printerName: string; 600 601 /** 602 * Current printer state. 603 * @type { PrinterState } 604 * @syscap SystemCapability.Print.PrintFramework 605 * @systemapi 606 * @since 10 607 */ 608 printerState: PrinterState; 609 610 /** 611 * Resource id of printer icon. 612 * @type { ?number } 613 * @syscap SystemCapability.Print.PrintFramework 614 * @systemapi 615 * @since 10 616 */ 617 printerIcon?: number; 618 619 /** 620 * Printer description. 621 * @type { ?string } 622 * @syscap SystemCapability.Print.PrintFramework 623 * @systemapi 624 * @since 10 625 */ 626 description?: string; 627 628 /** 629 * Printer capability. 630 * @type { ?PrinterCapability } 631 * @syscap SystemCapability.Print.PrintFramework 632 * @systemapi 633 * @since 10 634 */ 635 capability?: PrinterCapability; 636 637 /** 638 * JSON object string. 639 * @type { ?Object } 640 * @syscap SystemCapability.Print.PrintFramework 641 * @systemapi 642 * @since 10 643 */ 644 options?: Object; 645 } 646 647 /** 648 * defines print job. 649 * @typedef PrintJob 650 * @syscap SystemCapability.Print.PrintFramework 651 * @systemapi Hide this for inner system use. 652 * @since 10 653 */ 654 interface PrintJob { 655 /** 656 * Document fd list to be printed. 657 * @type { Array<number> } 658 * @syscap SystemCapability.Print.PrintFramework 659 * @systemapi 660 * @since 10 661 */ 662 fdList: Array<number>; 663 664 /** 665 * Job id. 666 * @type { string } 667 * @syscap SystemCapability.Print.PrintFramework 668 * @systemapi 669 * @since 10 670 */ 671 jobId: string; 672 673 /** 674 * Printer id to take charge of printing. 675 * @type { string } 676 * @syscap SystemCapability.Print.PrintFramework 677 * @systemapi 678 * @since 10 679 */ 680 printerId: string; 681 682 /** 683 * Current print job state. 684 * @type { PrintJobState } 685 * @syscap SystemCapability.Print.PrintFramework 686 * @systemapi 687 * @since 10 688 */ 689 jobState: PrintJobState; 690 691 /** 692 * Current print job sub state. 693 * @type { PrintJobSubState } 694 * @syscap SystemCapability.Print.PrintFramework 695 * @systemapi 696 * @since 11 697 */ 698 jobSubstate: PrintJobSubState; 699 700 /** 701 * Copies of document list. 702 * @type { number } 703 * @syscap SystemCapability.Print.PrintFramework 704 * @systemapi 705 * @since 10 706 */ 707 copyNumber: number; 708 709 /** 710 * Range size to be printed. 711 * @type { PrinterRange } 712 * @syscap SystemCapability.Print.PrintFramework 713 * @systemapi 714 * @since 10 715 */ 716 pageRange: PrinterRange; 717 718 /** 719 * Sequential print. 720 * @type { boolean } 721 * @syscap SystemCapability.Print.PrintFramework 722 * @systemapi 723 * @since 10 724 */ 725 isSequential: boolean; 726 727 /** 728 * The selected page size. 729 * @type { PrintPageSize } 730 * @syscap SystemCapability.Print.PrintFramework 731 * @systemapi 732 * @since 10 733 */ 734 pageSize: PrintPageSize; 735 736 /** 737 * Vertical printing. 738 * @type { boolean } 739 * @syscap SystemCapability.Print.PrintFramework 740 * @systemapi 741 * @since 10 742 */ 743 isLandscape: boolean; 744 745 /** 746 * Color mode. 747 * @type { number } 748 * @syscap SystemCapability.Print.PrintFramework 749 * @systemapi 750 * @since 10 751 */ 752 colorMode: number; 753 754 /** 755 * Duplex mode. 756 * @type { number } 757 * @syscap SystemCapability.Print.PrintFramework 758 * @systemapi 759 * @since 10 760 */ 761 duplexMode: number; 762 763 /** 764 * Current margin setting. 765 * @type { ?PrintMargin } 766 * @syscap SystemCapability.Print.PrintFramework 767 * @systemapi 768 * @since 10 769 */ 770 margin?: PrintMargin; 771 772 /** 773 * Preview setting. 774 * @type { ?PreviewAttribute } 775 * @syscap SystemCapability.Print.PrintFramework 776 * @systemapi 777 * @since 10 778 */ 779 preview?: PreviewAttribute; 780 781 /** 782 * JSON object string. 783 * @type { ?Object } 784 * @syscap SystemCapability.Print.PrintFramework 785 * @systemapi 786 * @since 10 787 */ 788 options?: Object; 789 } 790 791 /** 792 * Enumeration of Print Direction Mode. 793 * @enum { number } PrintDirectionMode 794 * @syscap SystemCapability.Print.PrintFramework 795 * @since 11 796 */ 797 enum PrintDirectionMode { 798 /** 799 * Automatically select direction. 800 * @syscap SystemCapability.Print.PrintFramework 801 * @since 11 802 */ 803 DIRECTION_MODE_AUTO = 0, 804 805 /** 806 * Print portrait. 807 * @syscap SystemCapability.Print.PrintFramework 808 * @since 11 809 */ 810 DIRECTION_MODE_PORTRAIT = 1, 811 812 /** 813 * Print landscape. 814 * @syscap SystemCapability.Print.PrintFramework 815 * @since 11 816 */ 817 DIRECTION_MODE_LANDSCAPE = 2, 818 } 819 820 /** 821 * Enumeration of Print Color Mode. 822 * @enum { number } PrintColorMode 823 * @syscap SystemCapability.Print.PrintFramework 824 * @since 11 825 */ 826 enum PrintColorMode { 827 /** 828 * Print monochrome. 829 * @syscap SystemCapability.Print.PrintFramework 830 * @since 11 831 */ 832 COLOR_MODE_MONOCHROME = 0, 833 834 /** 835 * Color printing. 836 * @syscap SystemCapability.Print.PrintFramework 837 * @since 11 838 */ 839 COLOR_MODE_COLOR = 1, 840 } 841 842 /** 843 * Enumeration of Print Duplex Mode. 844 * @enum { number } PrintDuplexMode 845 * @syscap SystemCapability.Print.PrintFramework 846 * @since 11 847 */ 848 enum PrintDuplexMode { 849 /** 850 * Single side printing. 851 * @syscap SystemCapability.Print.PrintFramework 852 * @since 11 853 */ 854 DUPLEX_MODE_NONE = 0, 855 856 /** 857 * Long-edge flip-up duplex printing. 858 * @syscap SystemCapability.Print.PrintFramework 859 * @since 11 860 */ 861 DUPLEX_MODE_LONG_EDGE = 1, 862 863 /** 864 * Short-edge flip-up duplex printing. 865 * @syscap SystemCapability.Print.PrintFramework 866 * @since 11 867 */ 868 DUPLEX_MODE_SHORT_EDGE = 2, 869 } 870 871 /** 872 * Enumeration of Print Page Type. 873 * @enum { number } PrintPageType 874 * @syscap SystemCapability.Print.PrintFramework 875 * @since 11 876 */ 877 enum PrintPageType { 878 /** 879 * A3 page. 880 * @syscap SystemCapability.Print.PrintFramework 881 * @since 11 882 */ 883 PAGE_ISO_A3 = 0, 884 885 /** 886 * A4 page. 887 * @syscap SystemCapability.Print.PrintFramework 888 * @since 11 889 */ 890 PAGE_ISO_A4 = 1, 891 892 /** 893 * A5 page. 894 * @syscap SystemCapability.Print.PrintFramework 895 * @since 11 896 */ 897 PAGE_ISO_A5 = 2, 898 899 /** 900 * B5 page. 901 * @syscap SystemCapability.Print.PrintFramework 902 * @since 11 903 */ 904 PAGE_JIS_B5 = 3, 905 906 /** 907 * C5 page. 908 * @syscap SystemCapability.Print.PrintFramework 909 * @since 11 910 */ 911 PAGE_ISO_C5 = 4, 912 913 /** 914 * DL Envelope. 915 * @syscap SystemCapability.Print.PrintFramework 916 * @since 11 917 */ 918 PAGE_ISO_DL = 5, 919 920 /** 921 * Letter. 922 * @syscap SystemCapability.Print.PrintFramework 923 * @since 11 924 */ 925 PAGE_LETTER = 6, 926 927 /** 928 * Legal. 929 * @syscap SystemCapability.Print.PrintFramework 930 * @since 11 931 */ 932 PAGE_LEGAL = 7, 933 934 /** 935 * Photo 4x6. 936 * @syscap SystemCapability.Print.PrintFramework 937 * @since 11 938 */ 939 PAGE_PHOTO_4X6 = 8, 940 941 /** 942 * Photo 5x7. 943 * @syscap SystemCapability.Print.PrintFramework 944 * @since 11 945 */ 946 PAGE_PHOTO_5X7 = 9, 947 948 /** 949 * Envelope INT DL. 950 * @syscap SystemCapability.Print.PrintFramework 951 * @since 11 952 */ 953 PAGE_INT_DL_ENVELOPE = 10, 954 955 /** 956 * Tabloid B. 957 * @syscap SystemCapability.Print.PrintFramework 958 * @since 11 959 */ 960 PAGE_B_TABLOID = 11, 961 } 962 963 /** 964 * Enumeration of Print Document Adapter State. 965 * @enum { number } PrintDocumentAdapterState 966 * @syscap SystemCapability.Print.PrintFramework 967 * @since 11 968 */ 969 enum PrintDocumentAdapterState { 970 /** 971 * Preview failed. 972 * @syscap SystemCapability.Print.PrintFramework 973 * @since 11 974 */ 975 PREVIEW_DESTROY = 0, 976 977 /** 978 * Print state is succeed. 979 * @syscap SystemCapability.Print.PrintFramework 980 * @since 11 981 */ 982 PRINT_TASK_SUCCEED = 1, 983 984 /** 985 * Print state is fail. 986 * @syscap SystemCapability.Print.PrintFramework 987 * @since 11 988 */ 989 PRINT_TASK_FAIL = 2, 990 991 /** 992 * Print state is cancel. 993 * @syscap SystemCapability.Print.PrintFramework 994 * @since 11 995 */ 996 PRINT_TASK_CANCEL = 3, 997 998 /** 999 * Print state is block. 1000 * @syscap SystemCapability.Print.PrintFramework 1001 * @since 11 1002 */ 1003 PRINT_TASK_BLOCK = 4, 1004 } 1005 1006 /** 1007 * Enumeration of Print File Creation State. 1008 * @enum { number } PrintFileCreationState 1009 * @syscap SystemCapability.Print.PrintFramework 1010 * @since 11 1011 */ 1012 enum PrintFileCreationState { 1013 /** 1014 * Print file created success. 1015 * @syscap SystemCapability.Print.PrintFramework 1016 * @since 11 1017 */ 1018 PRINT_FILE_CREATED = 0, 1019 1020 /** 1021 * Print file created fail. 1022 * @syscap SystemCapability.Print.PrintFramework 1023 * @since 11 1024 */ 1025 PRINT_FILE_CREATION_FAILED = 1, 1026 1027 /** 1028 * Print file created success but unrendered. 1029 * @syscap SystemCapability.Print.PrintFramework 1030 * @since 11 1031 */ 1032 PRINT_FILE_CREATED_UNRENDERED = 2, 1033 } 1034 1035 /** 1036 * Enumeration of Printer State. 1037 * @enum { number } PrinterState 1038 * @syscap SystemCapability.Print.PrintFramework 1039 * @since 14 1040 */ 1041 enum PrinterState { 1042 /** 1043 * New printers arrival. 1044 * @syscap SystemCapability.Print.PrintFramework 1045 * @since 14 1046 */ 1047 PRINTER_ADDED = 0, 1048 1049 /** 1050 * Printer lost. 1051 * @syscap SystemCapability.Print.PrintFramework 1052 * @since 14 1053 */ 1054 PRINTER_REMOVED = 1, 1055 1056 /** 1057 * Printer update. 1058 * @syscap SystemCapability.Print.PrintFramework 1059 * @since 14 1060 */ 1061 PRINTER_CAPABILITY_UPDATED = 2, 1062 1063 /** 1064 * Printer has been connected. 1065 * @syscap SystemCapability.Print.PrintFramework 1066 * @since 14 1067 */ 1068 PRINTER_CONNECTED = 3, 1069 1070 /** 1071 * Printer has been disconnected. 1072 * @syscap SystemCapability.Print.PrintFramework 1073 * @since 14 1074 */ 1075 PRINTER_DISCONNECTED = 4, 1076 1077 /** 1078 * Printer is working. 1079 * @syscap SystemCapability.Print.PrintFramework 1080 * @since 14 1081 */ 1082 PRINTER_RUNNING = 5, 1083 } 1084 1085 /** 1086 * Enumeration of Print Job State. 1087 * @enum { number } PrintJobState 1088 * @syscap SystemCapability.Print.PrintFramework 1089 * @since 14 1090 */ 1091 enum PrintJobState { 1092 /** 1093 * Initial state of print job. 1094 * @syscap SystemCapability.Print.PrintFramework 1095 * @since 14 1096 */ 1097 PRINT_JOB_PREPARE = 0, 1098 1099 /** 1100 * Deliver print job to the printer. 1101 * @syscap SystemCapability.Print.PrintFramework 1102 * @since 14 1103 */ 1104 PRINT_JOB_QUEUED = 1, 1105 1106 /** 1107 * Executing print job. 1108 * @syscap SystemCapability.Print.PrintFramework 1109 * @since 14 1110 */ 1111 PRINT_JOB_RUNNING = 2, 1112 1113 /** 1114 * Print job has been blocked. 1115 * @syscap SystemCapability.Print.PrintFramework 1116 * @since 14 1117 */ 1118 PRINT_JOB_BLOCKED = 3, 1119 1120 /** 1121 * Print job completed. 1122 * @syscap SystemCapability.Print.PrintFramework 1123 * @since 14 1124 */ 1125 PRINT_JOB_COMPLETED = 4, 1126 } 1127 1128 /** 1129 * Enumeration of Print Job Sub State. 1130 * @enum { number } PrintJobSubState 1131 * @syscap SystemCapability.Print.PrintFramework 1132 * @since 14 1133 */ 1134 enum PrintJobSubState { 1135 /** 1136 * Print job succeed. 1137 * @syscap SystemCapability.Print.PrintFramework 1138 * @since 14 1139 */ 1140 PRINT_JOB_COMPLETED_SUCCESS = 0, 1141 1142 /** 1143 * Print job fail. 1144 * @syscap SystemCapability.Print.PrintFramework 1145 * @since 14 1146 */ 1147 PRINT_JOB_COMPLETED_FAILED = 1, 1148 1149 /** 1150 * Print job has been cancelled. 1151 * @syscap SystemCapability.Print.PrintFramework 1152 * @since 14 1153 */ 1154 PRINT_JOB_COMPLETED_CANCELLED = 2, 1155 1156 /** 1157 * Print job has been corrupted. 1158 * @syscap SystemCapability.Print.PrintFramework 1159 * @since 14 1160 */ 1161 PRINT_JOB_COMPLETED_FILE_CORRUPTED = 3, 1162 1163 /** 1164 * Print is offline. 1165 * @syscap SystemCapability.Print.PrintFramework 1166 * @since 14 1167 */ 1168 PRINT_JOB_BLOCK_OFFLINE = 4, 1169 1170 /** 1171 * Print is occupied by other process. 1172 * @syscap SystemCapability.Print.PrintFramework 1173 * @since 14 1174 */ 1175 PRINT_JOB_BLOCK_BUSY = 5, 1176 1177 /** 1178 * Print job has been cancelled. 1179 * @syscap SystemCapability.Print.PrintFramework 1180 * @since 14 1181 */ 1182 PRINT_JOB_BLOCK_CANCELLED = 6, 1183 1184 /** 1185 * Print out of paper. 1186 * @syscap SystemCapability.Print.PrintFramework 1187 * @since 14 1188 */ 1189 PRINT_JOB_BLOCK_OUT_OF_PAPER = 7, 1190 1191 /** 1192 * Print out of ink. 1193 * @syscap SystemCapability.Print.PrintFramework 1194 * @since 14 1195 */ 1196 PRINT_JOB_BLOCK_OUT_OF_INK = 8, 1197 1198 /** 1199 * Print out of toner. 1200 * @syscap SystemCapability.Print.PrintFramework 1201 * @since 14 1202 */ 1203 PRINT_JOB_BLOCK_OUT_OF_TONER = 9, 1204 1205 /** 1206 * Print paper jam. 1207 * @syscap SystemCapability.Print.PrintFramework 1208 * @since 14 1209 */ 1210 PRINT_JOB_BLOCK_JAMMED = 10, 1211 1212 /** 1213 * Print cover open. 1214 * @syscap SystemCapability.Print.PrintFramework 1215 * @since 14 1216 */ 1217 PRINT_JOB_BLOCK_DOOR_OPEN = 11, 1218 1219 /** 1220 * Print service request. 1221 * @syscap SystemCapability.Print.PrintFramework 1222 * @since 14 1223 */ 1224 PRINT_JOB_BLOCK_SERVICE_REQUEST = 12, 1225 1226 /** 1227 * Print low on ink. 1228 * @syscap SystemCapability.Print.PrintFramework 1229 * @since 14 1230 */ 1231 PRINT_JOB_BLOCK_LOW_ON_INK = 13, 1232 1233 /** 1234 * Print low on toner. 1235 * @syscap SystemCapability.Print.PrintFramework 1236 * @since 14 1237 */ 1238 PRINT_JOB_BLOCK_LOW_ON_TONER = 14, 1239 1240 /** 1241 * Print really low on ink. 1242 * @syscap SystemCapability.Print.PrintFramework 1243 * @since 14 1244 */ 1245 PRINT_JOB_BLOCK_REALLY_LOW_ON_INK = 15, 1246 1247 /** 1248 * Print bad certification. 1249 * @syscap SystemCapability.Print.PrintFramework 1250 * @since 14 1251 */ 1252 PRINT_JOB_BLOCK_BAD_CERTIFICATE = 16, 1253 1254 /** 1255 * Print an error occurred when printing the account. 1256 * @syscap SystemCapability.Print.PrintFramework 1257 * @since 14 1258 */ 1259 PRINT_JOB_BLOCK_ACCOUNT_ERROR = 18, 1260 1261 /** 1262 * Print the printing permission is abnormal. 1263 * @syscap SystemCapability.Print.PrintFramework 1264 * @since 14 1265 */ 1266 PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR = 19, 1267 1268 /** 1269 * Print color printing permission exception. 1270 * @syscap SystemCapability.Print.PrintFramework 1271 * @since 14 1272 */ 1273 PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR = 20, 1274 1275 /** 1276 * Print the device is not connected to the network. 1277 * @syscap SystemCapability.Print.PrintFramework 1278 * @since 14 1279 */ 1280 PRINT_JOB_BLOCK_NETWORK_ERROR = 21, 1281 1282 /** 1283 * Print unable to connect to the server. 1284 * @syscap SystemCapability.Print.PrintFramework 1285 * @since 14 1286 */ 1287 PRINT_JOB_BLOCK_SERVER_CONNECTION_ERROR = 22, 1288 1289 /** 1290 * Print large file exception. 1291 * @syscap SystemCapability.Print.PrintFramework 1292 * @since 14 1293 */ 1294 PRINT_JOB_BLOCK_LARGE_FILE_ERROR = 23, 1295 1296 /** 1297 * Print file parsing exception. 1298 * @syscap SystemCapability.Print.PrintFramework 1299 * @since 14 1300 */ 1301 PRINT_JOB_BLOCK_FILE_PARSING_ERROR = 24, 1302 1303 /** 1304 * Print the file conversion is too slow. 1305 * @syscap SystemCapability.Print.PrintFramework 1306 * @since 14 1307 */ 1308 PRINT_JOB_BLOCK_SLOW_FILE_CONVERSION = 25, 1309 1310 /** 1311 * Print uploading file. 1312 * @syscap SystemCapability.Print.PrintFramework 1313 * @since 14 1314 */ 1315 PRINT_JOB_RUNNING_UPLOADING_FILES = 26, 1316 1317 /** 1318 * Print converting files. 1319 * @syscap SystemCapability.Print.PrintFramework 1320 * @since 14 1321 */ 1322 PRINT_JOB_RUNNING_CONVERTING_FILES = 27, 1323 1324 /** 1325 * Print unknown issue. 1326 * @syscap SystemCapability.Print.PrintFramework 1327 * @since 14 1328 */ 1329 PRINT_JOB_BLOCK_UNKNOWN = 99, 1330 } 1331 1332 /** 1333 * Enumeration of Print error Code. 1334 * @enum { number } PrintErrorCode 1335 * @syscap SystemCapability.Print.PrintFramework 1336 * @since 14 1337 */ 1338 enum PrintErrorCode { 1339 /** 1340 * No error. 1341 * @syscap SystemCapability.Print.PrintFramework 1342 * @since 14 1343 */ 1344 E_PRINT_NONE = 0, 1345 1346 /** 1347 * No permission. 1348 * @syscap SystemCapability.Print.PrintFramework 1349 * @since 14 1350 */ 1351 E_PRINT_NO_PERMISSION = 201, 1352 1353 /** 1354 * Invalid parameter. 1355 * @syscap SystemCapability.Print.PrintFramework 1356 * @since 14 1357 */ 1358 E_PRINT_INVALID_PARAMETER = 401, 1359 1360 /** 1361 * Generic failure of print. 1362 * @syscap SystemCapability.Print.PrintFramework 1363 * @since 14 1364 */ 1365 E_PRINT_GENERIC_FAILURE = 13100001, 1366 1367 /** 1368 * RPC failure. 1369 * @syscap SystemCapability.Print.PrintFramework 1370 * @since 14 1371 */ 1372 E_PRINT_RPC_FAILURE = 13100002, 1373 1374 /** 1375 * Failure of print service. 1376 * @syscap SystemCapability.Print.PrintFramework 1377 * @since 14 1378 */ 1379 E_PRINT_SERVER_FAILURE = 13100003, 1380 1381 /** 1382 * Invalid print extension. 1383 * @syscap SystemCapability.Print.PrintFramework 1384 * @since 14 1385 */ 1386 E_PRINT_INVALID_EXTENSION = 13100004, 1387 1388 /** 1389 * Invalid printer. 1390 * @syscap SystemCapability.Print.PrintFramework 1391 * @since 14 1392 */ 1393 E_PRINT_INVALID_PRINTER = 13100005, 1394 1395 /** 1396 * Invalid print job. 1397 * @syscap SystemCapability.Print.PrintFramework 1398 * @since 14 1399 */ 1400 E_PRINT_INVALID_PRINT_JOB = 13100006, 1401 1402 /** 1403 * File i/o error. 1404 * @syscap SystemCapability.Print.PrintFramework 1405 * @since 14 1406 */ 1407 E_PRINT_FILE_IO = 13100007, 1408 } 1409 1410 /** 1411 * Enumeration of application event. 1412 * @enum { number } ApplicationEvent 1413 * @syscap SystemCapability.Print.PrintFramework 1414 * @since 14 1415 */ 1416 enum ApplicationEvent { 1417 /** 1418 * Application created. 1419 * @syscap SystemCapability.Print.PrintFramework 1420 * @since 14 1421 */ 1422 APPLICATION_CREATED = 0, 1423 1424 /** 1425 * Application closed for printing started. 1426 * @syscap SystemCapability.Print.PrintFramework 1427 * @since 14 1428 */ 1429 APPLICATION_CLOSED_FOR_STARTED = 1, 1430 1431 /** 1432 * Application closed for printing canceled. 1433 * @syscap SystemCapability.Print.PrintFramework 1434 * @since 14 1435 */ 1436 APPLICATION_CLOSED_FOR_CANCELED = 2, 1437 } 1438 1439 /** 1440 * defines print ExtensionInfo. 1441 * @typedef PrinterExtensionInfo 1442 * @syscap SystemCapability.Print.PrintFramework 1443 * @systemapi Hide this for inner system use. 1444 * @since 10 1445 */ 1446 interface PrinterExtensionInfo { 1447 /** 1448 * Extension id of printer extension. 1449 * @type { string } 1450 * @syscap SystemCapability.Print.PrintFramework 1451 * @systemapi 1452 * @since 10 1453 */ 1454 extensionId: string; 1455 1456 /** 1457 * Vendor id of extension. 1458 * @type { string } 1459 * @syscap SystemCapability.Print.PrintFramework 1460 * @systemapi 1461 * @since 10 1462 */ 1463 vendorId: string; 1464 1465 /** 1466 * Vendor name. 1467 * @type { string } 1468 * @syscap SystemCapability.Print.PrintFramework 1469 * @systemapi 1470 * @since 10 1471 */ 1472 vendorName: string; 1473 1474 /** 1475 * Vendor icon. 1476 * @type { number } 1477 * @syscap SystemCapability.Print.PrintFramework 1478 * @systemapi 1479 * @since 10 1480 */ 1481 vendorIcon: number; 1482 1483 /** 1484 * Version of current printer extension. 1485 * @type { string } 1486 * @syscap SystemCapability.Print.PrintFramework 1487 * @systemapi 1488 * @since 10 1489 */ 1490 version: string; 1491 } 1492 1493 /** 1494 * Get all printer extension installed. 1495 * @permission ohos.permission.MANAGE_PRINT_JOB 1496 * @param { AsyncCallback<Array<PrinterExtensionInfo>> } callback - The callback function for handling the extension list found. 1497 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1498 * @throws { BusinessError } 202 - not system application 1499 * @syscap SystemCapability.Print.PrintFramework 1500 * @systemapi Hide this for inner system use. 1501 * @since 10 1502 */ 1503 function queryAllPrinterExtensionInfos(callback: AsyncCallback<Array<PrinterExtensionInfo>>): void; 1504 1505 /** 1506 * Get all printer extension installed. 1507 * @permission ohos.permission.MANAGE_PRINT_JOB 1508 * @returns { Promise<Array<PrinterExtensionInfo>> } the promise returned by the function. 1509 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1510 * @throws { BusinessError } 202 - not system application 1511 * @syscap SystemCapability.Print.PrintFramework 1512 * @systemapi Hide this for inner system use. 1513 * @since 10 1514 */ 1515 function queryAllPrinterExtensionInfos(): Promise<Array<PrinterExtensionInfo>>; 1516 1517 /** 1518 * Load the specific printer extension and start to discover printer. 1519 * @permission ohos.permission.MANAGE_PRINT_JOB 1520 * @param { Array<string> } extensionList - Indicates the list of printer extension. 1521 * empty list of extensionList Indicates to find printer with all installed extension. 1522 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1523 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1524 * @throws { BusinessError } 202 - not system application 1525 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1526 * @syscap SystemCapability.Print.PrintFramework 1527 * @systemapi Hide this for inner system use. 1528 * @since 10 1529 */ 1530 function startDiscoverPrinter(extensionList: Array<string>, callback: AsyncCallback<void>): void; 1531 1532 /** 1533 * Load the specific printer extension and start to discover printer. 1534 * @permission ohos.permission.MANAGE_PRINT_JOB 1535 * @param { Array<string> } extensionList - Indicates the list of printer extension. 1536 * empty list of extensionList Indicates to find printer with all installed extension. 1537 * @returns { Promise<void> } the promise returned by the function. 1538 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1539 * @throws { BusinessError } 202 - not system application 1540 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1541 * @syscap SystemCapability.Print.PrintFramework 1542 * @systemapi Hide this for inner system use. 1543 * @since 10 1544 */ 1545 function startDiscoverPrinter(extensionList: Array<string>): Promise<void>; 1546 1547 /** 1548 * Stop discovering the printer with specific printer extension. 1549 * @permission ohos.permission.MANAGE_PRINT_JOB 1550 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1551 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1552 * @throws { BusinessError } 202 - not system application 1553 * @syscap SystemCapability.Print.PrintFramework 1554 * @systemapi Hide this for inner system use. 1555 * @since 10 1556 */ 1557 function stopDiscoverPrinter(callback: AsyncCallback<void>): void; 1558 1559 /** 1560 * Stop discovering the printer with specific printer extension. 1561 * @permission ohos.permission.MANAGE_PRINT_JOB 1562 * @returns { Promise<void> } the promise returned by the function. 1563 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1564 * @throws { BusinessError } 202 - not system application 1565 * @syscap SystemCapability.Print.PrintFramework 1566 * @systemapi Hide this for inner system use. 1567 * @since 10 1568 */ 1569 function stopDiscoverPrinter(): Promise<void>; 1570 1571 /** 1572 * Connect the specific printer. 1573 * @permission ohos.permission.MANAGE_PRINT_JOB 1574 * @param { string } printerId - Indicates id of the printer. 1575 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1576 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1577 * @throws { BusinessError } 202 - not system application 1578 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1579 * @syscap SystemCapability.Print.PrintFramework 1580 * @systemapi Hide this for inner system use. 1581 * @since 10 1582 */ 1583 function connectPrinter(printerId: string, callback: AsyncCallback<void>): void; 1584 1585 /** 1586 * Connect the specific printer. 1587 * @permission ohos.permission.MANAGE_PRINT_JOB 1588 * @param { string } printerId - Indicates id of the printer. 1589 * @returns { Promise<void> } the promise returned by the function. 1590 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1591 * @throws { BusinessError } 202 - not system application 1592 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1593 * @syscap SystemCapability.Print.PrintFramework 1594 * @systemapi Hide this for inner system use. 1595 * @since 10 1596 */ 1597 function connectPrinter(printerId: string): Promise<void>; 1598 1599 /** 1600 * Disconnect the specific printer. 1601 * @permission ohos.permission.MANAGE_PRINT_JOB 1602 * @param { string } printerId - Indicates id of the printer. 1603 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1604 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1605 * @throws { BusinessError } 202 - not system application 1606 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1607 * @syscap SystemCapability.Print.PrintFramework 1608 * @systemapi Hide this for inner system use. 1609 * @since 10 1610 */ 1611 function disconnectPrinter(printerId: string, callback: AsyncCallback<void>): void; 1612 1613 /** 1614 * Disconnect the specific printer. 1615 * @permission ohos.permission.MANAGE_PRINT_JOB 1616 * @param { string } printerId - Indicates id of the printer. 1617 * @returns { Promise<void> } the promise returned by the function. 1618 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1619 * @throws { BusinessError } 202 - not system application 1620 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1621 * @syscap SystemCapability.Print.PrintFramework 1622 * @systemapi Hide this for inner system use. 1623 * @since 10 1624 */ 1625 function disconnectPrinter(printerId: string): Promise<void>; 1626 1627 /** 1628 * Query capability for the specific printer. 1629 * @permission ohos.permission.MANAGE_PRINT_JOB 1630 * @param { string } printerId - Indicates id of the printer. 1631 * @param { AsyncCallback<void> } callback - The callback function for capability from printer. 1632 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1633 * @throws { BusinessError } 202 - not system application 1634 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1635 * @syscap SystemCapability.Print.PrintFramework 1636 * @systemapi Hide this for inner system use. 1637 * @since 10 1638 */ 1639 function queryPrinterCapability(printerId: string, callback: AsyncCallback<void>): void; 1640 1641 /** 1642 * Query capability for the specific printer. 1643 * @permission ohos.permission.MANAGE_PRINT_JOB 1644 * @param { string } printerId - Indicates id of the printer. 1645 * @returns { Promise<void> } the promise returned by the function. 1646 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1647 * @throws { BusinessError } 202 - not system application 1648 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1649 * @syscap SystemCapability.Print.PrintFramework 1650 * @systemapi Hide this for inner system use. 1651 * @since 10 1652 */ 1653 function queryPrinterCapability(printerId: string): Promise<void>; 1654 1655 /** 1656 * Start print job. 1657 * @permission ohos.permission.MANAGE_PRINT_JOB 1658 * @param { PrintJob } jobInfo - Indicates the information of print job. 1659 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1660 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1661 * @throws { BusinessError } 202 - not system application 1662 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1663 * @syscap SystemCapability.Print.PrintFramework 1664 * @systemapi Hide this for inner system use. 1665 * @since 10 1666 */ 1667 function startPrintJob(jobInfo: PrintJob, callback: AsyncCallback<void>): void; 1668 1669 /** 1670 * Start print job. 1671 * @permission ohos.permission.MANAGE_PRINT_JOB 1672 * @param { PrintJob } jobInfo - Indicates the information of print job. 1673 * @returns { Promise<void> } the promise returned by the function. 1674 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1675 * @throws { BusinessError } 202 - not system application 1676 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1677 * @syscap SystemCapability.Print.PrintFramework 1678 * @systemapi Hide this for inner system use. 1679 * @since 10 1680 */ 1681 function startPrintJob(jobInfo: PrintJob): Promise<void>; 1682 1683 /** 1684 * Cancel the print job has been sent to printer. 1685 * @permission ohos.permission.MANAGE_PRINT_JOB 1686 * @param { string } jobId - Indicates the specific print job. 1687 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1688 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1689 * @throws { BusinessError } 202 - not system application 1690 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1691 * @syscap SystemCapability.Print.PrintFramework 1692 * @systemapi Hide this for inner system use. 1693 * @since 10 1694 */ 1695 function cancelPrintJob(jobId: string, callback: AsyncCallback<void>): void; 1696 1697 /** 1698 * Cancel the print job has been sent to printer. 1699 * @permission ohos.permission.MANAGE_PRINT_JOB 1700 * @param { string } jobId - Indicates the specific print job. 1701 * @returns { Promise<void> } the promise returned by the function. 1702 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1703 * @throws { BusinessError } 202 - not system application 1704 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1705 * @syscap SystemCapability.Print.PrintFramework 1706 * @systemapi Hide this for inner system use. 1707 * @since 10 1708 */ 1709 function cancelPrintJob(jobId: string): Promise<void>; 1710 1711 /** 1712 * Request preview of the print job. 1713 * @permission ohos.permission.MANAGE_PRINT_JOB 1714 * @param { PrintJob } jobInfo - Indicates the information of print job. 1715 * @param { Callback<number> } callback - The callback function for indcating the result of API execution. 1716 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1717 * @throws { BusinessError } 202 - not system application 1718 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1719 * @syscap SystemCapability.Print.PrintFramework 1720 * @systemapi Hide this for inner system use. 1721 * @since 10 1722 */ 1723 function requestPrintPreview(jobInfo: PrintJob, callback: Callback<number>): void; 1724 1725 /** 1726 * Request preview of the print job. 1727 * @permission ohos.permission.MANAGE_PRINT_JOB 1728 * @param { PrintJob } jobInfo - Indicates the information of print job. 1729 * @returns { Promise<number> } the promise returned by the function. 1730 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1731 * @throws { BusinessError } 202 - not system application 1732 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1733 * @syscap SystemCapability.Print.PrintFramework 1734 * @systemapi Hide this for inner system use. 1735 * @since 10 1736 */ 1737 function requestPrintPreview(jobInfo: PrintJob): Promise<number>; 1738 1739 /** 1740 * Register event callback for the state change of printer. 1741 * @permission ohos.permission.MANAGE_PRINT_JOB 1742 * @param { 'printerStateChange' } type - Indicates state change of printer. 1743 * @param { function } callback - The callback function for state change of printer. 1744 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1745 * @throws { BusinessError } 202 - not system application 1746 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1747 * @syscap SystemCapability.Print.PrintFramework 1748 * @systemapi Hide this for inner system use. 1749 * @since 10 1750 */ 1751 function on(type: 'printerStateChange', callback: (state: PrinterState, info: PrinterInfo) => void): void; 1752 1753 /** 1754 * Unregister event callback for the state change of printer. 1755 * @permission ohos.permission.MANAGE_PRINT_JOB 1756 * @param { 'printerStateChange' } type - Indicates state change of printer. 1757 * @param { Callback<boolean> } callback - The callback function for state change of printer. 1758 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1759 * @throws { BusinessError } 202 - not system application 1760 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1761 * @syscap SystemCapability.Print.PrintFramework 1762 * @systemapi Hide this for inner system use. 1763 * @since 10 1764 */ 1765 function off(type: 'printerStateChange', callback?: Callback<boolean>): void; 1766 1767 /** 1768 * Register event callback for the state change of print job. 1769 * @permission ohos.permission.MANAGE_PRINT_JOB 1770 * @param { 'jobStateChange' } type - Indicates state change of printer. 1771 * @param { function } callback - The callback function for state change of printer. 1772 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1773 * @throws { BusinessError } 202 - not system application 1774 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1775 * @syscap SystemCapability.Print.PrintFramework 1776 * @systemapi Hide this for inner system use. 1777 * @since 10 1778 */ 1779 function on(type: 'jobStateChange', callback: (state: PrintJobState, job: PrintJob) => void): void; 1780 1781 /** 1782 * Unregister event callback for the state change of print job. 1783 * @permission ohos.permission.MANAGE_PRINT_JOB 1784 * @param { 'jobStateChange' } type - Indicates state change of printer. 1785 * @param { Callback<boolean> } callback - The callback function for state change of printer. 1786 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1787 * @throws { BusinessError } 202 - not system application 1788 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1789 * @syscap SystemCapability.Print.PrintFramework 1790 * @systemapi Hide this for inner system use. 1791 * @since 10 1792 */ 1793 function off(type: 'jobStateChange', callback?: Callback<boolean>): void; 1794 1795 /** 1796 * Register event callback for the information change of print extension. 1797 * @permission ohos.permission.MANAGE_PRINT_JOB 1798 * @param { 'extInfoChange' } type - Indicates information change of print extension. 1799 * @param { function } callback - The callback function for information change of print extension. 1800 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1801 * @throws { BusinessError } 202 - not system application 1802 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1803 * @syscap SystemCapability.Print.PrintFramework 1804 * @systemapi Hide this for inner system use. 1805 * @since 10 1806 */ 1807 function on(type: 'extInfoChange', callback: (extensionId: string, info: string) => void): void; 1808 1809 /** 1810 * Unregister event callback for the information change of print extension. 1811 * @permission ohos.permission.MANAGE_PRINT_JOB 1812 * @param { 'extInfoChange' } type - Indicates state change of printer. 1813 * @param { Callback<boolean> } callback - The callback function for state change of printer. 1814 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1815 * @throws { BusinessError } 202 - not system application 1816 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1817 * @syscap SystemCapability.Print.PrintFramework 1818 * @systemapi Hide this for inner system use. 1819 * @since 10 1820 */ 1821 function off(type: 'extInfoChange', callback?: Callback<boolean>): void; 1822 1823 /** 1824 * New printers have been found and notify Print SA. 1825 * @permission ohos.permission.MANAGE_PRINT_JOB 1826 * @param { Array<PrinterInfo> } printers - Indicates new arrived printer lists. 1827 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1828 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1829 * @throws { BusinessError } 202 - not system application 1830 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1831 * @syscap SystemCapability.Print.PrintFramework 1832 * @systemapi Hide this for inner system use. 1833 * @since 10 1834 */ 1835 function addPrinters(printers: Array<PrinterInfo>, callback: AsyncCallback<void>): void; 1836 1837 /** 1838 * New printers have been found and notify Print SA. 1839 * @permission ohos.permission.MANAGE_PRINT_JOB 1840 * @param { Array<PrinterInfo> } printers - Indicates new arrived printer lists. 1841 * @returns { Promise<void> } the promise returned by the function. 1842 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1843 * @throws { BusinessError } 202 - not system application 1844 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1845 * @syscap SystemCapability.Print.PrintFramework 1846 * @systemapi Hide this for inner system use. 1847 * @since 10 1848 */ 1849 function addPrinters(printers: Array<PrinterInfo>): Promise<void>; 1850 1851 /** 1852 * Printers have been lost and notify Print SA. 1853 * @permission ohos.permission.MANAGE_PRINT_JOB 1854 * @param { Array<string> } printerIds - Indicates the lost printer lists. 1855 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1856 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1857 * @throws { BusinessError } 202 - not system application 1858 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1859 * @syscap SystemCapability.Print.PrintFramework 1860 * @systemapi Hide this for inner system use. 1861 * @since 10 1862 */ 1863 function removePrinters(printerIds: Array<string>, callback: AsyncCallback<void>): void; 1864 1865 /** 1866 * Printers have been lost and notify Print SA. 1867 * @permission ohos.permission.MANAGE_PRINT_JOB 1868 * @param { Array<string> } printerIds - Indicates the lost printer lists. 1869 * @returns { Promise<void> } the promise returned by the function. 1870 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1871 * @throws { BusinessError } 202 - not system application 1872 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1873 * @syscap SystemCapability.Print.PrintFramework 1874 * @systemapi Hide this for inner system use. 1875 * @since 10 1876 */ 1877 function removePrinters(printerIds: Array<string>): Promise<void>; 1878 1879 /** 1880 * Update the information of the specific printers. 1881 * @permission ohos.permission.MANAGE_PRINT_JOB 1882 * @param { Array<PrinterInfo> } printers - Indicates to be updated printer lists. 1883 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1884 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1885 * @throws { BusinessError } 202 - not system application 1886 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1887 * @syscap SystemCapability.Print.PrintFramework 1888 * @systemapi Hide this for inner system use. 1889 * @since 10 1890 */ 1891 function updatePrinters(printers: Array<PrinterInfo>, callback: AsyncCallback<void>): void; 1892 1893 /** 1894 * Update the information of the specific printers. 1895 * @permission ohos.permission.MANAGE_PRINT_JOB 1896 * @param { Array<PrinterInfo> } printers - Indicates to be updated printer lists. 1897 * @returns { Promise<void> } the promise returned by the function. 1898 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1899 * @throws { BusinessError } 202 - not system application 1900 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1901 * @syscap SystemCapability.Print.PrintFramework 1902 * @systemapi Hide this for inner system use. 1903 * @since 10 1904 */ 1905 function updatePrinters(printers: Array<PrinterInfo>): Promise<void>; 1906 1907 /** 1908 * Notify Print SA the state of printer has been changed. 1909 * @permission ohos.permission.MANAGE_PRINT_JOB 1910 * @param { string } printerId - Indicates id of the printer. 1911 * @param { PrinterState } state - Indicates state of the printer. 1912 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1913 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1914 * @throws { BusinessError } 202 - not system application 1915 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1916 * @syscap SystemCapability.Print.PrintFramework 1917 * @systemapi Hide this for inner system use. 1918 * @since 10 1919 */ 1920 function updatePrinterState(printerId: string, state: PrinterState, callback: AsyncCallback<void>): void; 1921 1922 /** 1923 * Notify Print SA the state of printer has been changed. 1924 * @permission ohos.permission.MANAGE_PRINT_JOB 1925 * @param { string } printerId - Indicates id of the printer. 1926 * @param { PrinterState } state - Indicates state of the printer. 1927 * @returns { Promise<void> } the promise returned by the function. 1928 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1929 * @throws { BusinessError } 202 - not system application 1930 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1931 * @syscap SystemCapability.Print.PrintFramework 1932 * @systemapi Hide this for inner system use. 1933 * @since 10 1934 */ 1935 function updatePrinterState(printerId: string, state: PrinterState): Promise<void>; 1936 1937 /** 1938 * Notify Print SA the state of print job has been changed. 1939 * @permission ohos.permission.MANAGE_PRINT_JOB 1940 * @param { string} jobId - Indicates id of the print job. 1941 * @param { PrintJobState } state - Indicates new state of print job. 1942 * @param { PrintJobSubState } subState - Indicates sub state of print job. 1943 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1944 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1945 * @throws { BusinessError } 202 - not system application 1946 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1947 * @syscap SystemCapability.Print.PrintFramework 1948 * @systemapi Hide this for inner system use. 1949 * @since 10 1950 */ 1951 function updatePrintJobState(jobId: string, state: PrintJobState, subState: PrintJobSubState, callback: AsyncCallback<void>): void; 1952 1953 /** 1954 * Notify Print SA the state of print job has been changed. 1955 * @permission ohos.permission.MANAGE_PRINT_JOB 1956 * @param { string} jobId - Indicates id of the print job. 1957 * @param { PrintJobState } state - Indicates new state of print job. 1958 * @param { PrintJobSubState } subState - Indicates sub state of print job. 1959 * @returns { Promise<void> } the promise returned by the function. 1960 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1961 * @throws { BusinessError } 202 - not system application 1962 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1963 * @syscap SystemCapability.Print.PrintFramework 1964 * @systemapi Hide this for inner system use. 1965 * @since 10 1966 */ 1967 function updatePrintJobState(jobId: string, state: PrintJobState, subState: PrintJobSubState): Promise<void>; 1968 1969 /** 1970 * Notify Print SA the state of print extension has been changed. 1971 * @permission ohos.permission.MANAGE_PRINT_JOB 1972 * @param { string } info - Indicates changed information of print extension. 1973 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 1974 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1975 * @throws { BusinessError } 202 - not system application 1976 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1977 * @syscap SystemCapability.Print.PrintFramework 1978 * @systemapi Hide this for inner system use. 1979 * @since 10 1980 */ 1981 function updateExtensionInfo(info: string, callback: AsyncCallback<void>): void; 1982 1983 /** 1984 * Notify Print SA the state of print extension has been changed. 1985 * @permission ohos.permission.MANAGE_PRINT_JOB 1986 * @param { string } info - Indicates changed information of print extension. 1987 * @returns { Promise<void> } the promise returned by the function. 1988 * @throws { BusinessError } 201 - the application does not have permission to call this function. 1989 * @throws { BusinessError } 202 - not system application 1990 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1991 * @syscap SystemCapability.Print.PrintFramework 1992 * @systemapi Hide this for inner system use. 1993 * @since 10 1994 */ 1995 function updateExtensionInfo(info: string): Promise<void>; 1996 1997 /** 1998 * Get all the printJobs in the queue. 1999 * @permission ohos.permission.MANAGE_PRINT_JOB 2000 * @param { AsyncCallback<void> } callback - The callback function for handling the printJob list found. 2001 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2002 * @throws { BusinessError } 202 - not system application 2003 * @syscap SystemCapability.Print.PrintFramework 2004 * @systemapi Hide this for inner system use. 2005 * @since 10 2006 * @deprecated since 11 2007 * @useinstead print#queryPrintJobList 2008 */ 2009 function queryAllPrintJobs(callback: AsyncCallback<void>): void; 2010 2011 /** 2012 * Get all the printJobs in the queue. 2013 * @permission ohos.permission.MANAGE_PRINT_JOB 2014 * @returns { Promise<void> } the promise returned by the function. 2015 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2016 * @throws { BusinessError } 202 - not system application 2017 * @syscap SystemCapability.Print.PrintFramework 2018 * @systemapi Hide this for inner system use. 2019 * @since 10 2020 * @deprecated since 11 2021 * @useinstead print#queryPrintJobList 2022 */ 2023 function queryAllPrintJobs(): Promise<void>; 2024 2025 /** 2026 * Get all the printJobs in the queue. 2027 * @permission ohos.permission.MANAGE_PRINT_JOB 2028 * @param { AsyncCallback<Array<PrintJob>> } callback - The callback function for handling the printJob list found. 2029 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2030 * @throws { BusinessError } 202 - not system application 2031 * @syscap SystemCapability.Print.PrintFramework 2032 * @systemapi Hide this for inner system use. 2033 * @since 11 2034 */ 2035 function queryPrintJobList(callback: AsyncCallback<Array<PrintJob>>): void; 2036 2037 /** 2038 * Get all the printJobs in the queue. 2039 * @permission ohos.permission.MANAGE_PRINT_JOB 2040 * @returns { Promise<Array<PrintJob>> } the promise returned by the function. 2041 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2042 * @throws { BusinessError } 202 - not system application 2043 * @syscap SystemCapability.Print.PrintFramework 2044 * @systemapi Hide this for inner system use. 2045 * @since 11 2046 */ 2047 function queryPrintJobList(): Promise<Array<PrintJob>>; 2048 2049 /** 2050 * Get printJob by jobId. 2051 * @permission ohos.permission.MANAGE_PRINT_JOB 2052 * @param { string } jobId - Indicates id of the print job. 2053 * @param { AsyncCallback<PrintJob> } callback - The callback function for get printJob by jobId. 2054 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2055 * @throws { BusinessError } 202 - not system application 2056 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2057 * @syscap SystemCapability.Print.PrintFramework 2058 * @systemapi Hide this for inner system use. 2059 * @since 11 2060 */ 2061 function queryPrintJobById(jobId: string, callback: AsyncCallback<PrintJob>): void; 2062 2063 /** 2064 * Get printJob by jobId. 2065 * @permission ohos.permission.MANAGE_PRINT_JOB 2066 * @param { string } jobId - Indicates id of the print job. 2067 * @returns { Promise<PrintJob> } the promise returned by the function. 2068 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2069 * @throws { BusinessError } 202 - not system application 2070 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2071 * @syscap SystemCapability.Print.PrintFramework 2072 * @systemapi Hide this for inner system use. 2073 * @since 11 2074 */ 2075 function queryPrintJobById(jobId: string): Promise<PrintJob>; 2076 2077 /** 2078 * Start getting print file. 2079 * @permission ohos.permission.MANAGE_PRINT_JOB 2080 * @param { string } jobId - Indicates id of the print job. 2081 * @param { PrintAttributes } printAttributes - Indicates print attributes. 2082 * @param { number } fd - Indicates print file fd. 2083 * @param { Callback<PrintFileCreationState> } onFileStateChanged - The callback function for update the file state. 2084 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2085 * @throws { BusinessError } 202 - not system application 2086 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2087 * @syscap SystemCapability.Print.PrintFramework 2088 * @systemapi Hide this for inner system use. 2089 * @since 11 2090 */ 2091 function startGettingPrintFile(jobId: string, printAttributes: PrintAttributes, fd: number, 2092 onFileStateChanged: Callback<PrintFileCreationState>): void; 2093 2094 /** 2095 * Notify print service the information. 2096 * @permission ohos.permission.MANAGE_PRINT_JOB 2097 * @param { string } jobId - Indicates id of the print job. 2098 * @param { 'spooler_closed_for_cancelled' | 'spooler_closed_for_started' } type - Indicates notify information. 2099 * @param { AsyncCallback<void> } callback - The callback function for indcating the result of API execution. 2100 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2101 * @throws { BusinessError } 202 - not system application 2102 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2103 * @syscap SystemCapability.Print.PrintFramework 2104 * @systemapi Hide this for inner system use. 2105 * @since 11 2106 */ 2107 function notifyPrintService(jobId: string, type: 'spooler_closed_for_cancelled' | 'spooler_closed_for_started', callback: AsyncCallback<void>): void; 2108 2109 /** 2110 * Notify print service the information. 2111 * @permission ohos.permission.MANAGE_PRINT_JOB 2112 * @param { string } jobId - Indicates id of the print job. 2113 * @param { 'spooler_closed_for_cancelled' | 'spooler_closed_for_started' } type - Indicates notify information. 2114 * @returns { Promise<void> } the promise returned by the function. 2115 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2116 * @throws { BusinessError } 202 - not system application 2117 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2118 * @syscap SystemCapability.Print.PrintFramework 2119 * @systemapi Hide this for inner system use. 2120 * @since 11 2121 */ 2122 function notifyPrintService(jobId: string, type: 'spooler_closed_for_cancelled' | 'spooler_closed_for_started'): Promise<void>; 2123 2124 /** 2125 * Get all added printers. 2126 * @permission ohos.permission.MANAGE_PRINT_JOB 2127 * @returns { Promise<Array<string>> } the promise returned by the function. 2128 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2129 * @throws { BusinessError } 202 - not system application 2130 * @syscap SystemCapability.Print.PrintFramework 2131 * @systemapi Hide this for inner system use. 2132 * @since 12 2133 */ 2134 function getAddedPrinters(): Promise<Array<string>>; 2135 2136 /** 2137 * Get printer info by printer id. 2138 * @permission ohos.permission.MANAGE_PRINT_JOB 2139 * @param { string } printerId - Indicates id of the printer. 2140 * @returns { Promise<PrinterInfo> } the promise returned by the function. 2141 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2142 * @throws { BusinessError } 202 - not system application 2143 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2144 * @syscap SystemCapability.Print.PrintFramework 2145 * @systemapi Hide this for inner system use. 2146 * @since 12 2147 */ 2148 function getPrinterInfoById(printerId: string): Promise<PrinterInfo>; 2149 2150 /** 2151 * Notify print service of application event. 2152 * @permission ohos.permission.MANAGE_PRINT_JOB 2153 * @param { ApplicationEvent } event - Indicates the event to be notified. 2154 * @returns { Promise<void> } the promise returned by the function. 2155 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2156 * @throws { BusinessError } 202 - not system application 2157 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2158 * @syscap SystemCapability.Print.PrintFramework 2159 * @systemapi Hide this for inner system use. 2160 * @since 12 2161 */ 2162 function notifyPrintServiceEvent(event: ApplicationEvent): Promise<void>; 2163 2164 /** 2165 * New printers have been found and notify Print SA. 2166 * @permission ohos.permission.PRINT 2167 * @param { PrinterInformation } printerInformation - Indicates new arrived printer lists. 2168 * @returns { Promise<void> } the promise returned by the function. 2169 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2170 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2171 * @syscap SystemCapability.Print.PrintFramework 2172 * @since 14 2173 */ 2174 function addPrinterToDiscovery(printerInformation: PrinterInformation): Promise<void>; 2175 2176 /** 2177 * Update the information of the specific printer. 2178 * @permission ohos.permission.PRINT 2179 * @param { PrinterInformation } printerInformation - Indicates to be updated printer lists. 2180 * @returns { Promise<void> } the promise returned by the function. 2181 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2182 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2183 * @syscap SystemCapability.Print.PrintFramework 2184 * @since 14 2185 */ 2186 function updatePrinterInDiscovery(printerInformation: PrinterInformation): Promise<void>; 2187 2188 /** 2189 * Notify Print SA to remove printer. 2190 * @permission ohos.permission.PRINT 2191 * @param { string } printerId - Indicates the lost printer lists. 2192 * @returns { Promise<void> } the promise returned by the function. 2193 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2194 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2195 * @syscap SystemCapability.Print.PrintFramework 2196 * @since 14 2197 */ 2198 function removePrinterFromDiscovery(printerId: string): Promise<void>; 2199 2200 /** 2201 * Get printerInformation by printer id. 2202 * @permission ohos.permission.PRINT 2203 * @param { string } printerId - Indicates id of the printer. 2204 * @returns { Promise<PrinterInformation> } the promise returned by the function. 2205 * @throws { BusinessError } 201 - the application does not have permission to call this function. 2206 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2207 * @syscap SystemCapability.Print.PrintFramework 2208 * @since 14 2209 */ 2210 function getPrinterInformationById(printerId: string): Promise<PrinterInformation>; 2211 2212 /** 2213 * defines printer information. 2214 * @typedef PrinterInformation 2215 * @syscap SystemCapability.Print.PrintFramework 2216 * @since 14 2217 */ 2218 interface PrinterInformation { 2219 /** 2220 * Printer id. 2221 * @type { string } 2222 * @syscap SystemCapability.Print.PrintFramework 2223 * @since 14 2224 */ 2225 printerId: string; 2226 2227 /** 2228 * Printer name. 2229 * @type { string } 2230 * @syscap SystemCapability.Print.PrintFramework 2231 * @since 14 2232 */ 2233 printerName: string; 2234 2235 /** 2236 * Current printer status. 2237 * @type { PrinterStatus } 2238 * @syscap SystemCapability.Print.PrintFramework 2239 * @since 14 2240 */ 2241 printerStatus: PrinterStatus; 2242 2243 /** 2244 * Printer description. 2245 * @type { ?string } 2246 * @syscap SystemCapability.Print.PrintFramework 2247 * @since 14 2248 */ 2249 description?: string; 2250 2251 /** 2252 * Printer capabilities. 2253 * @type { ?PrinterCapabilities } 2254 * @syscap SystemCapability.Print.PrintFramework 2255 * @since 14 2256 */ 2257 capability?: PrinterCapabilities; 2258 2259 /** 2260 * Printer uri. 2261 * @type { ?string } 2262 * @syscap SystemCapability.Print.PrintFramework 2263 * @since 14 2264 */ 2265 uri?: string; 2266 2267 /** 2268 * Printer make. 2269 * @type { ?string } 2270 * @syscap SystemCapability.Print.PrintFramework 2271 * @since 14 2272 */ 2273 printerMake?: string; 2274 2275 /** 2276 * Detail information in json format. 2277 * @type { ?string } 2278 * @syscap SystemCapability.Print.PrintFramework 2279 * @since 14 2280 */ 2281 options?: string; 2282 } 2283 2284 /** 2285 * defines printer capabilities. 2286 * @typedef PrinterCapabilities 2287 * @syscap SystemCapability.Print.PrintFramework 2288 * @since 14 2289 */ 2290 interface PrinterCapabilities { 2291 /** 2292 * The page size list supported by the printer. 2293 * @type { Array<PrintPageSize> } 2294 * @syscap SystemCapability.Print.PrintFramework 2295 * @since 14 2296 */ 2297 supportedPageSizes: Array<PrintPageSize>; 2298 2299 /** 2300 * Array of supported color mode. 2301 * @type { Array<PrintColorMode> } 2302 * @syscap SystemCapability.Print.PrintFramework 2303 * @since 14 2304 */ 2305 supportedColorModes: Array<PrintColorMode>; 2306 2307 /** 2308 * Array of supported duplex mode. 2309 * @type { Array<PrintDuplexMode> } 2310 * @syscap SystemCapability.Print.PrintFramework 2311 * @since 14 2312 */ 2313 supportedDuplexModes: Array<PrintDuplexMode>; 2314 2315 /** 2316 * Array of supported print media types. 2317 * @type { ?Array<string> } 2318 * @syscap SystemCapability.Print.PrintFramework 2319 * @since 14 2320 */ 2321 supportedMediaTypes?: Array<string>; 2322 2323 /** 2324 * Array of supported print quality. 2325 * @type { ?Array<PrintQuality> } 2326 * @syscap SystemCapability.Print.PrintFramework 2327 * @since 14 2328 */ 2329 supportedQualities?: Array<PrintQuality>; 2330 2331 /** 2332 * Array of supported print orientation. 2333 * @type { ?Array<PrintOrientationMode> } 2334 * @syscap SystemCapability.Print.PrintFramework 2335 * @since 14 2336 */ 2337 supportedOrientations?: Array<PrintOrientationMode>; 2338 2339 /** 2340 * Advanced capability in json format. 2341 * @type { ?string } 2342 * @syscap SystemCapability.Print.PrintFramework 2343 * @since 14 2344 */ 2345 options?: string; 2346 } 2347 2348 /** 2349 * Enumeration of Print Quality. 2350 * @enum { number } PrintQuality 2351 * @syscap SystemCapability.Print.PrintFramework 2352 * @since 14 2353 */ 2354 enum PrintQuality { 2355 /** 2356 * Draft quality mode. 2357 * @syscap SystemCapability.Print.PrintFramework 2358 * @since 14 2359 */ 2360 QUALITY_DRAFT = 3, 2361 2362 /** 2363 * Normal quality mode. 2364 * @syscap SystemCapability.Print.PrintFramework 2365 * @since 14 2366 */ 2367 QUALITY_NORMAL = 4, 2368 2369 /** 2370 * High quality mode. 2371 * @syscap SystemCapability.Print.PrintFramework 2372 * @since 14 2373 */ 2374 QUALITY_HIGH = 5, 2375 } 2376 2377 /** 2378 * Enumeration of Print OrientationMode. 2379 * @enum { number } PrintOrientationMode 2380 * @syscap SystemCapability.Print.PrintFramework 2381 * @since 14 2382 */ 2383 enum PrintOrientationMode { 2384 /** 2385 * Portrait mode. 2386 * @syscap SystemCapability.Print.PrintFramework 2387 * @since 14 2388 */ 2389 ORIENTATION_MODE_PORTRAIT = 0, 2390 2391 /** 2392 * Landscape mode. 2393 * @syscap SystemCapability.Print.PrintFramework 2394 * @since 14 2395 */ 2396 ORIENTATION_MODE_LANDSCAPE= 1, 2397 2398 /** 2399 * Reverse landscape mode. 2400 * @syscap SystemCapability.Print.PrintFramework 2401 * @since 14 2402 */ 2403 ORIENTATION_MODE_REVERSE_LANDSCAPE = 2, 2404 2405 /** 2406 * Reverse portrait mode. 2407 * @syscap SystemCapability.Print.PrintFramework 2408 * @since 14 2409 */ 2410 ORIENTATION_MODE_REVERSE_PORTRAIT = 3, 2411 2412 /** 2413 * Not specified. 2414 * @syscap SystemCapability.Print.PrintFramework 2415 * @since 14 2416 */ 2417 ORIENTATION_MODE_NONE = 4, 2418 } 2419 2420 /** 2421 * Enumeration of Printer Status. 2422 * @enum { number } PrinterStatus 2423 * @syscap SystemCapability.Print.PrintFramework 2424 * @since 14 2425 */ 2426 enum PrinterStatus { 2427 /** 2428 * Printer idle. 2429 * @syscap SystemCapability.Print.PrintFramework 2430 * @since 14 2431 */ 2432 PRINTER_IDLE = 0, 2433 2434 /** 2435 * Printer busy. 2436 * @syscap SystemCapability.Print.PrintFramework 2437 * @since 14 2438 */ 2439 PRINTER_BUSY = 1, 2440 2441 /** 2442 * Printer not available. 2443 * @syscap SystemCapability.Print.PrintFramework 2444 * @since 14 2445 */ 2446 PRINTER_UNAVAILABLE = 2, 2447 } 2448 2449} 2450 2451export default print;