• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Want from './@ohos.application.Want';
22import type print from './@ohos.print';
23
24/**
25 * class of print extensionAbility.
26 *
27 * @syscap SystemCapability.Print.PrintFramework
28 * @systemapi Hide this for inner system use.
29 * @StageModelOnly
30 * @since 10
31 */
32export default class PrintExtensionAbility {
33
34  /**
35   * Called once to initialize the extensionAbility.
36   * @param { Want } want - call print page want params.
37   * @throws { BusinessError } 202 - not system application
38   * @syscap SystemCapability.Print.PrintFramework
39   * @systemapi Hide this for inner system use.
40   * @StageModelOnly
41   * @since 10
42   */
43  onCreate(want: Want): void;
44
45  /**
46   * Called once to start to discover the printers connected with the device.
47   * @throws { BusinessError } 202 - not system application
48   * @syscap SystemCapability.Print.PrintFramework
49   * @systemapi Hide this for inner system use.
50   * @StageModelOnly
51   * @since 10
52   */
53  onStartDiscoverPrinter(): void;
54
55  /**
56   * Called once to stop discovering the printer.
57   * @throws { BusinessError } 202 - not system application
58   * @syscap SystemCapability.Print.PrintFramework
59   * @systemapi Hide this for inner system use.
60   * @StageModelOnly
61   * @since 10
62   */
63  onStopDiscoverPrinter(): void;
64
65  /**
66   * Called once to connect to the specific printer.
67   * @param { number } printerId - connect the printerId.
68   * @throws { BusinessError } 202 - not system application
69   * @syscap SystemCapability.Print.PrintFramework
70   * @systemapi Hide this for inner system use.
71   * @StageModelOnly
72   * @since 10
73   */
74  onConnectPrinter(printerId: number): void;
75
76  /**
77   * Called once to disconnect to the specific printer.
78   * @param { number } printerId - connect the printerId.
79   * @throws { BusinessError } 202 - not system application
80   * @syscap SystemCapability.Print.PrintFramework
81   * @systemapi Hide this for inner system use.
82   * @StageModelOnly
83   * @since 10
84   */
85  onDisconnectPrinter(printerId: number): void;
86
87  /**
88   * Called once to start print job.
89   * @param { print.PrintJob } jobInfo - Indicates the information of print job.
90   * @throws { BusinessError } 202 - not system application
91   * @syscap SystemCapability.Print.PrintFramework
92   * @systemapi Hide this for inner system use.
93   * @StageModelOnly
94   * @since 10
95   */
96  onStartPrintJob(jobInfo: print.PrintJob): void;
97
98  /**
99   * Called once to remove the print job has been started.
100   * @param { print.PrintJob } jobInfo - Indicates the information of print job.
101   * @throws { BusinessError } 202 - not system application
102   * @syscap SystemCapability.Print.PrintFramework
103   * @systemapi Hide this for inner system use.
104   * @StageModelOnly
105   * @since 10
106   */
107  onCancelPrintJob(jobInfo: print.PrintJob): void;
108
109  /**
110   * Called once to request the capability of the printer.
111   * @param { number } printerId - Indicates the information of printer.
112   * @returns { print.PrinterCapability } printer capability.
113   * @throws { BusinessError } 202 - not system application
114   * @syscap SystemCapability.Print.PrintFramework
115   * @systemapi Hide this for inner system use.
116   * @StageModelOnly
117   * @since 10
118   */
119  onRequestPrinterCapability(printerId: number): print.PrinterCapability;
120
121  /**
122   * Called once to request preview and send result to Print SA.
123   * @param {  print.PrintJob } jobInfo - Indicates the information of job.
124   * @returns { string} preview result.
125   * @throws { BusinessError } 202 - not system application
126   * @syscap SystemCapability.Print.PrintFramework
127   * @systemapi Hide this for inner system use.
128   * @StageModelOnly
129   * @since 10
130   */
131  onRequestPreview(jobInfo: print.PrintJob): string;
132
133  /**
134   * Called once to finalize the extensionAbility.
135   * @throws { BusinessError } 202 - not system application
136   * @syscap SystemCapability.Print.PrintFramework
137   * @systemapi Hide this for inner system use.
138   * @StageModelOnly
139   * @since 10
140   */
141  onDestroy(): void;
142}
143