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