Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5e0abd90
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5e0abd90
编写于
10月 11, 2022
作者:
@
@chuangda_1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add 1011 code
Signed-off-by:
N
@chuangda_1
<
fangwanning@huawei.com
>
上级
2e399d38
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
854 addition
and
201 deletion
+854
-201
zh-cn/application-dev/print/stage-printextensionability.md
zh-cn/application-dev/print/stage-printextensionability.md
+183
-0
zh-cn/application-dev/reference/apis/js-apis-print.md
zh-cn/application-dev/reference/apis/js-apis-print.md
+671
-201
未找到文件。
zh-cn/application-dev/print/stage-printextensionability.md
0 → 100644
浏览文件 @
5e0abd90
# PrintExtensionAbility开发指导
## 场景介绍
PrintExtensionAbility类定义了打印扩展生命周期方法,开发者可以自定义类继承PrintExtensionAbility,通过重写基类中相关生命周期方法,来实现打印机发现、连接,打印任务启动、取消,打印机能力和打印预览的查询等相关业务逻辑操作。
> **说明:**
>
> PrintExtensionAbility仅可在Stage模型下使用。
## 接口说明
**表1**
PrintExtensionAbility中相关生命周期API功能介绍
|接口名|描述|
|:------|:------|
|onCreated(want:
Want):
void| PrintExtension生命周期回调,在创建时回调,执行初始化业务逻辑操作。|
|onStartDiscoverPrinter():
void | PrintExtension生命周期回调,执行发现打印机业务逻辑操作。|
|onStopDiscoverPrinter():
void| PrintExtension生命周期回调,执行停止发现打印机业务逻辑操作。|
|onConnectPrinter(printerId:
number):
void| PrintExtension生命周期回调,执行连接打印机业务逻辑操作。
|onDisconnectPrinter(printerId:
number):
void|PrintExtension生命周期回调,执行连接打印机业务逻辑操作。|
|onStartPrintJob(jobInfo:
print.PrintJob):
void|PrintExtension生命周期回调,执行启动打印任务业务逻辑操作。|
|onCancelPrintJob(jobInfo:
print.PrintJob):
void| PrintExtension生命周期回调,执行取消打印任务业务逻辑操作。|
|onRequestPrinterCapability(printerId:
number):
print.PrinterCapability| PrintExtension生命周期回调,在print.queryPrinterCapability调用时回调,执行查询打印机能力业务逻辑操作。|
|onRequestPreview(jobInfo:
print.PrintJob):
string| PrintExtension生命周期回调,执行查询打印预览业务逻辑操作。|
|onDestroy():
void| PrintExtension生命周期回调,在销毁时回调,执行资源清理等操作。|
## 约束与限制
OpenHarmony当前不支持三方应用创建PrintExtensionAbility。
## 开发步骤
1.
需要在应用配置文件module.json5中进行注册,注册类型type需要设置为service。module.json5配置样例如下所示:
```
json
"extensionAbilities"
:[{
"name"
:
"CustomPrintExtensionAbility"
,
"srcEntrance"
:
"./ets/PrintExtensionAbility/CustomPrintExtensionAbility.ts"
,
"label"
:
"$string:form_FormAbility_label"
,
"description"
:
"$string:form_FormAbility_desc"
,
"type"
:
"service"
,
"metadata"
:
[
{
"name"
:
"ohos.extension.form"
,
"resource"
:
"$profile:form_config"
}
}
]
```
2.
请求权限。
需要在
`config.json`
文件里进行配置请求权限,用于使用打印相关API
[
打印管理API
](
../reference/apis/js-apis-print.md#print
)
,示例代码如下:
```json
{
"module": {
"reqPermissions": [
{
"name": "ohos.permission.MANAGE_PRINT_JOB"
}
]
}
}
```
3.
开发者在定义Service的目录下创建TS文件,自定义类继承PrintExtensionAbility,重写基类回调函数,接口生成的默认相对路径:entry
\s
rc
\m
ain
\e
ts
\P
rintExtensionAbility
\C
ustomPrintExtensionAbility.ts,示例如下:
```
js
import
PrintExtensionAbility
from
'
@ohos.PrintExtension
'
;
import
print
from
"
@ohos.print
"
;
import
Want
from
'
@ohos.application.Want
'
;
export
default
class
CustomPrintExtensionAbility
extends
PrintExtensionAbility
{
MODULE_TAG
:
string
=
"
customPrintExtensionAbility
"
onCreated
(
want
:
Want
):
void
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability on created start
'
);
}
onStartDiscoverPrinter
()
{
console
.
info
(
this
.
MODULE_TAG
+
"
ability start to discover printer
"
);
let
printer1
=
{
printerId
:
1
,
// printer id
printerName
:
'
string
'
,
// printer name
printerIcon
:
1
,
// resource id of printer icon
printerState
:
1
,
// current printer state
description
:
'
string
'
,
// printer description
capability
:
PrinterCapability
,
}
let
printer2
=
{
printerId
:
2
,
// printer id
printerName
:
'
char
'
,
// printer name
printerIcon
:
2
,
// resource id of printer icon
printerState
:
2
,
// current printer state
description
:
'
char
'
,
// printer description
capability
:
PrinterCapability
,
}
let
printers
=
[
printer1
,
printer2
]
print
.
addPrinters
(
printers
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
});
}
onStopDiscoverPrinter
()
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability stop discovering printer
'
);
}
onConnectPrinter
(
printerId
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability connect the speci1 printer
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onConnectPrinter printerId:
'
+
JSON
.
stringify
(
printerId
));
}
onDisconnectPrinter
(
printerId
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability disconnect the speci1 printer
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onDisconnectPrinter printerId:
'
+
JSON
.
stringify
(
printerId
));
}
onStartPrintJob
(
jobInfo
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability start Print Job
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onStartPrintJob jobInfo:
'
+
JSON
.
stringify
(
jobInfo
));
}
onCancelPrintJob
(
jobInfo
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability cancel Print Job
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onCancelPrintJob jobInfo:
'
+
JSON
.
stringify
(
jobInfo
));
}
onRequestPrinterCapability
(
printerId
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability request printer capability
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onRequestPrinterCapability printerId:
'
+
JSON
.
stringify
(
printerId
));
let
PrinterPageSizeArr
=
[
{
id
:
'
1
'
,
name
:
'
string
'
,
width
:
200
,
height
:
200
,
}
]
let
PrintMargin
=
{
top
:
1
,
bottom
:
2
,
left
:
1
,
right
:
1
,
}
let
PrinterResolutionArr
=
[
{
id
:
2
,
horizontalDpi
:
2
,
verticalDpi
:
1
,
}
]
let
cap
=
{
minMargin
:
PrintMargin
,
pageSize
:
PrinterPageSizeArr
,
resolution
:
PrinterResolutionArr
,
colorMode
:
1
,
duplexMode
:
2
,
}
return
cap
;
}
onRequestPreview
(
jobInfo
)
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability request printer preview
'
);
console
.
info
(
this
.
MODULE_TAG
+
'
onRequestPreview jobInfo:
'
+
JSON
.
stringify
(
jobInfo
));
}
onDestroy
()
{
console
.
info
(
this
.
MODULE_TAG
+
'
ability on destroy
'
);
}
};
```
## 相关实例
针对PrintExtensionAbility开发,有以下相关实例可供参考:
-
[
`Print_Extension_demo`:打印扩展(eTS)(API8)(Full SDK)
](
https://gitee.com/openharmony/applications_app_samples/tree/master/print/ServiceExtAbility
)
zh-cn/application-dev/reference/apis/js-apis-print.md
浏览文件 @
5e0abd90
...
@@ -50,16 +50,16 @@ SystemCapability.Print.print
...
@@ -50,16 +50,16 @@ SystemCapability.Print.print
let
files
:
Array
<
string
>
=
[
'
./data/app/sample.pdf
'
];
let
files
:
Array
<
string
>
=
[
'
./data/app/sample.pdf
'
];
print
.
print
(
files
,(
err
,
task
)
=>
{
print
.
print
(
files
,(
err
,
task
)
=>
{
task
.
on
(
'
blocked
'
,
()
=>
{
task
.
on
(
'
blocked
'
,
()
=>
{
console
.
info
(
"
print task block
ed
"
)
console
.
info
(
"
print task block
"
)
});
});
task
.
on
(
'
success
'
,
()
=>
{
task
.
on
(
'
success
'
,
()
=>
{
console
.
info
(
"
print task success
"
)
console
.
info
(
"
print task success
"
)
});
});
task
.
on
(
'
failed
'
,
()
=>
{
task
.
on
(
'
failed
'
,
()
=>
{
console
.
info
(
"
print task fail
ed
"
)
console
.
info
(
"
print task fail
"
)
});
});
task
.
on
(
'
cancelled
'
,
()
=>
{
task
.
on
(
'
cancelled
'
,
()
=>
{
console
.
info
(
"
print task cancel
led
"
)
console
.
info
(
"
print task cancel
"
)
});
});
});
});
```
```
...
@@ -96,16 +96,16 @@ SystemCapability.Print.print
...
@@ -96,16 +96,16 @@ SystemCapability.Print.print
let files: Array
<string>
= ['./data/app/sample.pdf'];
let files: Array
<string>
= ['./data/app/sample.pdf'];
print.print(files).then((task) => {
print.print(files).then((task) => {
task.on('blocked', () => {
task.on('blocked', () => {
console.info("print task block
ed
")
console.info("print task block")
});
});
task.on('success', () => {
task.on('success', () => {
console.info("print task success")
console.info("print task success")
});
});
task.on('failed', () => {
task.on('failed', () => {
console.info("print task fail
ed
")
console.info("print task fail")
});
});
task.on('cancelled', () => {
task.on('cancelled', () => {
console.info("print task cancel
led
")
console.info("print task cancel")
});
});
});
});
```
```
...
@@ -169,7 +169,7 @@ SystemCapability.Print.print
...
@@ -169,7 +169,7 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
print.query
ExtensionAbility
Infos()
print.query
AllPrinterExtension
Infos()
.then((data) => {
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
...
@@ -179,7 +179,7 @@ print.queryExtensionAbilityInfos()
...
@@ -179,7 +179,7 @@ print.queryExtensionAbilityInfos()
## print.startDiscoverPrinter
## print.startDiscoverPrinter
startDiscoverPrinter(extensionList: Array<
number
>, callback: AsyncCallback<boolean>): void;
startDiscoverPrinter(extensionList: Array<
string
>, callback: AsyncCallback<boolean>): void;
发现打印机(callback形式)。
发现打印机(callback形式)。
...
@@ -195,13 +195,13 @@ SystemCapability.Print.print
...
@@ -195,13 +195,13 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| extensionList | Array<
number
>| 否 | 扩展ID。|
| extensionList | Array<
string
>| 否 | 扩展ID。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
**示例:**
**示例:**
```js
```js
let extensionList
: number[] = [1,2
];
let extensionList
= ['1001','1002'
];
print.startDiscoverPrinter(extensionList, (err, data) => {
print.startDiscoverPrinter(extensionList, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
...
@@ -212,7 +212,7 @@ print.startDiscoverPrinter(extensionList, (err, data) => {
...
@@ -212,7 +212,7 @@ print.startDiscoverPrinter(extensionList, (err, data) => {
```
```
## print.startDiscoverPrinter
## print.startDiscoverPrinter
startDiscoverPrinter(extensionList: Array<
number
>): Promise<boolean>;
startDiscoverPrinter(extensionList: Array<
string
>): Promise<boolean>;
发现打印机(promise形式)。
发现打印机(promise形式)。
...
@@ -228,7 +228,7 @@ SystemCapability.Print.print
...
@@ -228,7 +228,7 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| extensionList | Array<
number
>| 否 | 扩展ID。|
| extensionList | Array<
string
>| 否 | 扩展ID。|
**返回值:**
**返回值:**
...
@@ -239,7 +239,7 @@ SystemCapability.Print.print
...
@@ -239,7 +239,7 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let extensionList
: number[] = [1,2
];
let extensionList
= ['1001','1002'
];
print.startDiscoverPrinter(extensionList)
print.startDiscoverPrinter(extensionList)
.then((data) => {
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
...
@@ -315,10 +315,9 @@ print.stopDiscoverPrinter().then((data) => {
...
@@ -315,10 +315,9 @@ print.stopDiscoverPrinter().then((data) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
})
```
```
## print.connectPrinter
## print.connectPrinter
connectPrinter(printerId:
number
, callback: AsyncCallback<boolean>): void;
connectPrinter(printerId:
string
, callback: AsyncCallback<boolean>): void;
发现打印机(callback形式)。
发现打印机(callback形式)。
...
@@ -334,13 +333,13 @@ SystemCapability.Print.print
...
@@ -334,13 +333,13 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 否 | 打印机ID。|
| printerId |
string
| 否 | 打印机ID。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.connectPrinter(printerId, (err, data) => {
print.connectPrinter(printerId, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
...
@@ -351,7 +350,7 @@ print.connectPrinter(printerId, (err, data) => {
...
@@ -351,7 +350,7 @@ print.connectPrinter(printerId, (err, data) => {
```
```
## print.connectPrinter
## print.connectPrinter
connectPrinter(printerId:
number
): Promise<boolean>;
connectPrinter(printerId:
string
): Promise<boolean>;
发现打印机(promise形式)。
发现打印机(promise形式)。
...
@@ -367,7 +366,7 @@ SystemCapability.Print.print
...
@@ -367,7 +366,7 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 否 | 打印机ID。|
| printerId |
string
| 否 | 打印机ID。|
**返回值:**
**返回值:**
...
@@ -378,7 +377,7 @@ SystemCapability.Print.print
...
@@ -378,7 +377,7 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.connectPrinter(printerId)
print.connectPrinter(printerId)
.then((data) => {
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
...
@@ -390,7 +389,7 @@ print.connectPrinter(printerId)
...
@@ -390,7 +389,7 @@ print.connectPrinter(printerId)
## print.disconnectPrinter
## print.disconnectPrinter
disconnectPrinter(printerId:
number
, callback: AsyncCallback<boolean>): void;
disconnectPrinter(printerId:
string
, callback: AsyncCallback<boolean>): void;
断开连接打印机(callback形式)。
断开连接打印机(callback形式)。
...
@@ -406,13 +405,13 @@ SystemCapability.Print.print
...
@@ -406,13 +405,13 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 否 | 打印机ID。|
| printerId |
string
| 否 | 打印机ID。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback<boolean> | 是 | 被指定的回调方法。 |
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.disconnectPrinter(printerId, (err, data) => {
print.disconnectPrinter(printerId, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
...
@@ -423,7 +422,7 @@ print.disconnectPrinter(printerId, (err, data) => {
...
@@ -423,7 +422,7 @@ print.disconnectPrinter(printerId, (err, data) => {
```
```
## print.disconnectPrinter
## print.disconnectPrinter
disconnectPrinter(printerId:
number
): Promise<boolean>;
disconnectPrinter(printerId:
string
): Promise<boolean>;
发现打印机(promise形式)。
发现打印机(promise形式)。
...
@@ -439,7 +438,7 @@ SystemCapability.Print.print
...
@@ -439,7 +438,7 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 否 | 打印机ID。|
| printerId |
string
| 否 | 打印机ID。|
**返回值:**
**返回值:**
...
@@ -450,7 +449,7 @@ SystemCapability.Print.print
...
@@ -450,7 +449,7 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.disconnectPrinter(printerId)
print.disconnectPrinter(printerId)
.then((data) => {
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
...
@@ -459,10 +458,9 @@ print.disconnectPrinter(printerId)
...
@@ -459,10 +458,9 @@ print.disconnectPrinter(printerId)
})
})
```
```
## print.queryPrinterCapability
## print.queryPrinterCapability
queryPrinterCapability(printerId:
number
, callback: AsyncCallback\<PrinterCapability>): void;
queryPrinterCapability(printerId:
string
, callback: AsyncCallback\<PrinterCapability>): void;
查询打印机能力(callback形式)。
查询打印机能力(callback形式)。
...
@@ -478,13 +476,13 @@ SystemCapability.Print.print
...
@@ -478,13 +476,13 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 是 | 打印机ID。|
| printerId |
string
| 是 | 打印机ID。|
| callback | AsyncCallback\<[PrinterCapability](#printerCapability)> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback\<[PrinterCapability](#printerCapability)> | 是 | 被指定的回调方法。 |
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.queryPrinterCapability(printerId, (err, data) => {
print.queryPrinterCapability(printerId, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
...
@@ -493,9 +491,10 @@ print.queryPrinterCapability(printerId, (err, data) => {
...
@@ -493,9 +491,10 @@ print.queryPrinterCapability(printerId, (err, data) => {
console.info('Operation successful. Data:' + JSON.stringify(data));
console.info('Operation successful. Data:' + JSON.stringify(data));
})
})
```
```
## print.queryPrinterCapability
## print.queryPrinterCapability
queryPrinterCapability(printerId:
number
): Promise<PrinterCapability>
queryPrinterCapability(printerId:
string
): Promise<PrinterCapability>
查询打印机能力(promise形式)。
查询打印机能力(promise形式)。
...
@@ -511,7 +510,7 @@ SystemCapability.Print.print
...
@@ -511,7 +510,7 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 是 | 打印机ID。|
| printerId |
string
| 是 | 打印机ID。|
**返回值:**
**返回值:**
...
@@ -522,7 +521,7 @@ SystemCapability.Print.print
...
@@ -522,7 +521,7 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printerId =
1
;
let printerId =
'1001'
;
print.queryPrinterCapability(printerId)
print.queryPrinterCapability(printerId)
.then((data) => {
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
...
@@ -531,7 +530,6 @@ print.queryPrinterCapability(printerId)
...
@@ -531,7 +530,6 @@ print.queryPrinterCapability(printerId)
})
})
```
```
## print.startPrintJob
## print.startPrintJob
startPrintJob(jobinfo: PrintJob, callback: AsyncCallback<boolean>): void;
startPrintJob(jobinfo: PrintJob, callback: AsyncCallback<boolean>): void;
...
@@ -580,8 +578,8 @@ let previewAttribute = {
...
@@ -580,8 +578,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -592,6 +590,7 @@ let printJob = {
...
@@ -592,6 +590,7 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:''
}
}
print.startPrintJob(PrintJob, (err, data) => {
print.startPrintJob(PrintJob, (err, data) => {
...
@@ -655,8 +654,8 @@ let previewAttribute = {
...
@@ -655,8 +654,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -667,6 +666,7 @@ let printJob = {
...
@@ -667,6 +666,7 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:'string'
}
}
print.startPrintJob(PrintJob).then((data)=>{
print.startPrintJob(PrintJob).then((data)=>{
...
@@ -723,8 +723,8 @@ let previewAttribute = {
...
@@ -723,8 +723,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -735,8 +735,8 @@ let printJob = {
...
@@ -735,8 +735,8 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:'string'
}
}
print.cancelPrintJob(printJob, (err, data) => {
print.cancelPrintJob(printJob, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
...
@@ -798,8 +798,8 @@ let previewAttribute = {
...
@@ -798,8 +798,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -810,8 +810,8 @@ let printJob = {
...
@@ -810,8 +810,8 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:''
}
}
print.cancelPrintJob(printJob).then((data)=>{
print.cancelPrintJob(printJob).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
...
@@ -866,8 +866,8 @@ let previewAttribute = {
...
@@ -866,8 +866,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -878,6 +878,7 @@ let printJob = {
...
@@ -878,6 +878,7 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:'string'
}
}
print.requestPrintPreview(printJob, (err, data) => {
print.requestPrintPreview(printJob, (err, data) => {
...
@@ -941,8 +942,8 @@ let previewAttribute = {
...
@@ -941,8 +942,8 @@ let previewAttribute = {
}
}
let printJob = {
let printJob = {
files:['D:/dev/a.docx'],
files:['D:/dev/a.docx'],
jobId:
3
,
jobId:
'1001'
,
printerId:
2
, // printer id to take charge of printing
printerId:
'2001'
, // printer id to take charge of printing
jobState: printerState, // current print job state
jobState: printerState, // current print job state
copyNumber: 3, // copies of document list
copyNumber: 3, // copies of document list
pageRange: printerRange,
pageRange: printerRange,
...
@@ -953,6 +954,7 @@ let printJob = {
...
@@ -953,6 +954,7 @@ let printJob = {
duplexMode: 1, // duplex mode
duplexMode: 1, // duplex mode
margin: printMargin, // current margin setting
margin: printMargin, // current margin setting
preview: previewAttribute, // preview setting
preview: previewAttribute, // preview setting
option:'string'
}
}
print.requestPrintPreview(printJob).then((data)=>{
print.requestPrintPreview(printJob).then((data)=>{
...
@@ -961,6 +963,7 @@ print.requestPrintPreview(printJob).then((data)=>{
...
@@ -961,6 +963,7 @@ print.requestPrintPreview(printJob).then((data)=>{
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
})
```
```
## print.on(type: 'printerStateChange')
## print.on(type: 'printerStateChange')
on(type: 'printerStateChange', callback: (state: PrinterState, info: PrinterInfo) => void): void;
on(type: 'printerStateChange', callback: (state: PrinterState, info: PrinterInfo) => void): void;
...
@@ -987,25 +990,25 @@ SystemCapability.Print.print
...
@@ -987,25 +990,25 @@ SystemCapability.Print.print
```js
```js
print.on('printerStateChange', (state, info) => {
print.on('printerStateChange', (state, info) => {
if (state == print.PrinterState.PRINTER_ADDED) {
if (state == print.PrinterState.PRINTER_ADDED) {
console.info("printer added. info: " + JSON.stringify(info));
console.info("printer
is
added. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_REMOVED) {
if (state == print.PrinterState.PRINTER_REMOVED) {
console.info("printer removed. info: " + JSON.stringify(info));
console.info("printer
is
removed. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_
IDLE
) {
if (state == print.PrinterState.PRINTER_
UPDATED
) {
console.info("printer i
dle
. info: " + JSON.stringify(info));
console.info("printer i
s updated
. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_
PRINTING
) {
if (state == print.PrinterState.PRINTER_
CONNECTED
) {
console.info("printer
printing
. info: " + JSON.stringify(info));
console.info("printer
is connected
. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_
BLOCK
ED) {
if (state == print.PrinterState.PRINTER_
DISCONNECT
ED) {
console.info("printer
block
ed. info: " + JSON.stringify(info));
console.info("printer
is disConnect
ed. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_
BUSY
) {
if (state == print.PrinterState.PRINTER_
RUNNING
) {
console.info("printer
busy
. info: " + JSON.stringify(info));
console.info("printer
is running
. info: " + JSON.stringify(info));
}
}
if (state == print.PrinterState.PRINTER_
FAILED
) {
if (state == print.PrinterState.PRINTER_
UNKNOWN
) {
console.info("printer
failed
. info: " + JSON.stringify(info));
console.info("printer
is unknown
. info: " + JSON.stringify(info));
}
}
});
});
```
```
...
@@ -1064,32 +1067,29 @@ SystemCapability.Print.print
...
@@ -1064,32 +1067,29 @@ SystemCapability.Print.print
```js
```js
print.on('jobStateChange', (state, info) => {
print.on('jobStateChange', (state, info) => {
if (state == print.PrintJobState.PRINT_JOB_
CREATED
) {
if (state == print.PrintJobState.PRINT_JOB_
PREPARE
) {
console.info("the print job is
created
. info:"+JSON.stringify(info));
console.info("the print job is
prepare
. info:"+JSON.stringify(info));
}
}
if (state == print.PrintJobState.PRINT_JOB_QUEUED) {
if (state == print.PrintJobState.PRINT_JOB_QUEUED) {
console.info("the print job is queued. info:"+JSON.stringify(info));
console.info("the print job is queued. info:"+JSON.stringify(info));
}
}
if (state == print.PrintJobState.PRINT_JOB_
PRINT
ING) {
if (state == print.PrintJobState.PRINT_JOB_
RUNN
ING) {
console.info("the print job is
print
ing. info:"+JSON.stringify(info));
console.info("the print job is
runn
ing. info:"+JSON.stringify(info));
}
}
if (state == print.PrintJobState.PRINT_JOB_BLOCKED) {
if (state == print.PrintJobState.PRINT_JOB_BLOCKED) {
console.info("the print job is blocked. info:"+JSON.stringify(info));
console.info("the print job is blocked. info:"+JSON.stringify(info));
}
}
if (state == print.PrintJobState.PRINT_JOB_
SUCCESS
) {
if (state == print.PrintJobState.PRINT_JOB_
COMPLETED
) {
console.info("the print job is
success
. info:"+JSON.stringify(info));
console.info("the print job is
completed
. info:"+JSON.stringify(info));
}
}
if (state == print.PrintJobState.PRINT_JOB_FAILED) {
if (state == print.PrintJobState.PRINT_JOB_UNKNOWN) {
console.info("the print job is failed. info:"+JSON.stringify(info));
console.info("the print job is unknown. info:"+JSON.stringify(info));
}
if (state == print.PrintJobState.PRINT_JOB_cancelled) {
console.info("the print job is cancelled. info:"+JSON.stringify(info));
}
}
});
});
```
```
## print.off('jobStateChange')
## print.off('jobStateChange')
off(type: 'jobStateChange', callback
: (boolean) => void): void;
off(type: 'jobStateChange', callback?
: (boolean) => void): void;
取消订阅printerStateChange事件
取消订阅printerStateChange事件
...
@@ -1116,6 +1116,65 @@ print.off('jobStateChange', (err, data) => {
...
@@ -1116,6 +1116,65 @@ print.off('jobStateChange', (err, data) => {
}
}
```
```
## print.on('extInfoChange')
on(type: 'extInfoChange', callback: (extensionId: string, info: string) => void): void;
订阅打印任务子状态变化事件。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string| 是 | 监听打印任务状态的变化。|
| callback | (extensionId: string, info: string) => void| 是 | 被指定的回调结果。 |
**示例:**
```js
print.on('extInfoChange', (extensionId, info) => {
console.info("extInfoChange on. info:"+JSON.stringify(info));
});
```
## print.off('extInfoChange')
off(type: 'extInfoChange', callback?: (boolean) => void): void;
订阅打印任务子状态变化事件。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string| 是 | 监听打印任务状态的变化。|
| callback | (info: string) => void | 是 | 被指定的回调结果。 |
**示例:**
```js
print.off('extInfoChange', (info) => {
console.info("extInfoChange off. info:"+JSON.stringify(info));
});
```
## print.addPrinters
## print.addPrinters
addPrinters(printers: Array\<PrinterInfo>, callback: AsyncCallback<boolean>): void;
addPrinters(printers: Array\<PrinterInfo>, callback: AsyncCallback<boolean>): void;
...
@@ -1140,26 +1199,56 @@ SystemCapability.Print.print
...
@@ -1140,26 +1199,56 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printerPageSizeArr = [
{
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
let printer1 = {
printerId:
1
, // printer id
printerId:
'1001'
, // printer id
printerName: '
string
', // printer name
printerName: '
打印机2
', // printer name
printerIcon: 1, // resource id of printer icon
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
printerState: 1, // current printer state
description: 'string', // printer description
description: '打印机1', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: 'string'
}
}
let printer2 = {
let printer2 = {
printerId:
2
, // printer id
printerId:
'1002'
, // printer id
printerName: '
char
', // printer name
printerName: '
打印机1
', // printer name
printerIcon: 2, // resource id of printer icon
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
printerState: 2, // current printer state
description: 'char', // printer description
description: '打印机2', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: 'string'
}
}
let printers = [printer1, printer2]
let printers = [printer1, printer2]
print.addPrinters(printers, (err, data) => {
print.addPrinters(printers, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
return;
...
@@ -1196,30 +1285,59 @@ SystemCapability.Print.print
...
@@ -1196,30 +1285,59 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printer1 = {
let printerPageSizeArr = [
printerId: 1, // printer id
{
printerName: 'string', // printer name
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
printerId: '1001', // printer id
printerName: '打印机2', // printer name
printerIcon: 1, // resource id of printer icon
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
printerState: 1, // current printer state
description: 'string', // printer description
description: '打印机1', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
}
let printer2 = {
let printer2 = {
printerId:
2
, // printer id
printerId:
'1002'
, // printer id
printerName: '
char
', // printer name
printerName: '
打印机1
', // printer name
printerIcon: 2, // resource id of printer icon
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
printerState: 2, // current printer state
description: 'char', // printer description
description: '打印机2', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
}
let printers = [printer1, printer2]
let printers = [printer1, printer2]
print.addPrinters(printers).then((data)=>{
print.addPrinters(printers).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
})
```
```
## print.removePrinters
## print.removePrinters
...
@@ -1246,26 +1364,55 @@ SystemCapability.Print.print
...
@@ -1246,26 +1364,55 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printerPageSizeArr = [
{
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
let printer1 = {
printerId:
1
, // printer id
printerId:
'1001'
, // printer id
printerName: '
string
', // printer name
printerName: '
打印机2
', // printer name
printerIcon: 1, // resource id of printer icon
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
printerState: 1, // current printer state
description: 'string', // printer description
description: '打印机1', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
}
let printer2 = {
let printer2 = {
printerId:
2
, // printer id
printerId:
'1002'
, // printer id
printerName: '
char
', // printer name
printerName: '
打印机1
', // printer name
printerIcon: 2, // resource id of printer icon
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
printerState: 2, // current printer state
description: 'char', // printer description
description: '打印机2', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
}
let printers = [printer1, printer2]
let printers = [printer1, printer2]
print.removePrinters(printers, (err, data) => {
print.removePrinters(printers, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
return;
...
@@ -1302,34 +1449,228 @@ SystemCapability.Print.print
...
@@ -1302,34 +1449,228 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let printer1 = {
let printerPageSizeArr = [
printerId: 1, // printer id
{
printerName: 'string', // printer name
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
printerId: '1001', // printer id
printerName: '打印机2', // printer name
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
description: '打印机1', // printer description
capability: printerCapability,
option: ''
}
let printer2 = {
printerId: '1002', // printer id
printerName: '打印机1', // printer name
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
description: '打印机2', // printer description
capability: printerCapability,
option: ''
}
let printers = [printer1, printer2]
print.removePrinters(printers).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## print.updatePrinters
updatePrinters(printers: Array<PrinterInfo>, callback: AsyncCallback<boolean>): void;
更新打印机(callback形式)。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| printers | Array\<[PrinterInfo](#PrinterInfo)>| 是 | 打印机信息。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
**示例:**
```js
let printerPageSizeArr = [
{
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
printerId: '1001', // printer id
printerName: '打印机2', // printer name
printerIcon: 1, // resource id of printer icon
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
printerState: 1, // current printer state
description: 'string', // printer description
description: '打印机1', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
}
let printer2 = {
let printer2 = {
printerId:
2
, // printer id
printerId:
'1002'
, // printer id
printerName: '
char
', // printer name
printerName: '
打印机1
', // printer name
printerIcon: 2, // resource id of printer icon
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
printerState: 2, // current printer state
description: 'char', // printer description
description: '打印机2', // printer description
capability: PrinterCapability,
capability: printerCapability,
option: ''
}
let printers = [printer1, printer2]
print.updatePrinters(printers, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## print.updatePrinters
updatePrinters(printers: Array<PrinterInfo>): Promise<boolean>;
更新打印机(promise形式)。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| printers | Array\<[PrinterInfo](#printerInfo)>| 是 | 打印机信息。|
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise<boolean> | Promise形式返回执行结果。 |
let printers = [printer1, printer2]
**示例:**
```js
let printerPageSizeArr = [
{
id: '1',
name: 'string',
width: 200,
height: 200,
}
]
let printMargin = {
top: 1,
bottom: 2,
left: 1,
right: 1,
}
let printerResolutionArr = [
{
id: 2,
horizontalDpi: 2,
verticalDpi: 1,
}
]
let printerCapability = {
minMargin: printMargin,
pageSize: printerPageSizeArr,
resolution: printerResolutionArr,
colorMode: 1,
duplexMode: 2,
}
let printer1 = {
printerId: '1001', // printer id
printerName: '打印机2', // printer name
printerIcon: 1, // resource id of printer icon
printerState: 1, // current printer state
description: '打印机1', // printer description
capability: printerCapability,
option: ''
}
let printer2 = {
printerId: '1002', // printer id
printerName: '打印机1', // printer name
printerIcon: 2, // resource id of printer icon
printerState: 2, // current printer state
description: '打印机2', // printer description
capability: printerCapability,
option: ''
}
print.removePrinters(printers).then((data)=>{
let printers = [printer1, printer2]
print.updatePrinters(printers).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
})
```
```
## print.updatePrinterState
## print.updatePrinterState
updatePrinterState(printerId:
number, state: PrinterState,
callback: AsyncCallback<boolean>): void;
updatePrinterState(printerId:
string, state: PrinterState,
callback: AsyncCallback<boolean>): void;
更新打印机状态(callback形式)。
更新打印机状态(callback形式)。
...
@@ -1345,16 +1686,16 @@ SystemCapability.Print.print
...
@@ -1345,16 +1686,16 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 是 | 打印机Id。|
| printerId |
string
| 是 | 打印机Id。|
| state | [PrinterState](#printerState)| 是 | 打印机状态。|
| state | [PrinterState](#printerState)| 是 | 打印机状态。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
**示例:**
**示例:**
```js
```js
let printerId =
3
;
let printerId =
'1002'
;
let printerState =
print.PrinterState.PRINTER_ADDED
;
let printerState =
1
;
print.updatePrinterState(printerId,printerState, (err, data) => {
print.updatePrinterState(printerId,
printerState, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
return;
...
@@ -1364,7 +1705,7 @@ print.updatePrinterState(printerId,printerState, (err, data) => {
...
@@ -1364,7 +1705,7 @@ print.updatePrinterState(printerId,printerState, (err, data) => {
```
```
## print.updatePrinterState
## print.updatePrinterState
updatePrinterState(printerId: number
, state: PrinterState): Promise<boolean>;
updatePrinterState(printerId: string
, state: PrinterState): Promise<boolean>;
更新打印机状态(promise形式)。
更新打印机状态(promise形式)。
...
@@ -1380,9 +1721,11 @@ SystemCapability.Print.print
...
@@ -1380,9 +1721,11 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| printerId |
number
| 是 | 打印机Id。|
| printerId |
string
| 是 | 打印机Id。|
| state | [PrinterState](#printerState)| 是 | 打印机状态。|
| state | [PrinterState](#printerState)| 是 | 打印机状态。|
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
...
@@ -1393,8 +1736,7 @@ SystemCapability.Print.print
...
@@ -1393,8 +1736,7 @@ SystemCapability.Print.print
```js
```js
let printerId = 3;
let printerId = 3;
let printerState = print.PrinterState.PRINTER_ADDED;
let printerState = 1;
print.updatePrinterState(printerId,printerState).then((data)=>{
print.updatePrinterState(printerId,printerState).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
...
@@ -1403,7 +1745,7 @@ print.updatePrinterState(printerId,printerState).then((data)=>{
...
@@ -1403,7 +1745,7 @@ print.updatePrinterState(printerId,printerState).then((data)=>{
```
```
## print.updatePrintJobState
## print.updatePrintJobState
updatePrintJobState(jobId:
number, state: PrintJo
bState, callback: AsyncCallback<boolean>): void;
updatePrintJobState(jobId:
string, state: PrintJobState, subState: PrintJobSu
bState, callback: AsyncCallback<boolean>): void;
更新打印任务状态(callback形式)。
更新打印任务状态(callback形式)。
...
@@ -1419,16 +1761,18 @@ SystemCapability.Print.print
...
@@ -1419,16 +1761,18 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| jobId |
number
| 是 | 打印任务Id。|
| jobId |
string
| 是 | 打印任务Id。|
| state | [PrintJobState](#printJobState)| 是 | 打印任务状态。|
| state | [PrintJobState](#printJobState)| 是 | 打印任务状态。|
| subState | [PrintJobSubState](#printJobSubState)| 是 | 打印任务状态。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
**示例:**
**示例:**
```js
```js
let jobId = 3;
let jobId = '1002';
let printJobState = print.PrintJobState.PRINT_JOB_CREATED;
let printJobState = 1;
print.updatePrintJobState(jobId,printJobState, (err, data) => {
let printJobSubState =2;
print.updatePrintJobState(jobId, printJobState, printJobSubState, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
return;
...
@@ -1438,7 +1782,7 @@ print.updatePrintJobState(jobId,printJobState, (err, data) => {
...
@@ -1438,7 +1782,7 @@ print.updatePrintJobState(jobId,printJobState, (err, data) => {
```
```
## print.updatePrintJobState
## print.updatePrintJobState
updatePrintJobState(jobId:
number, state: PrintJo
bState): Promise<boolean>;
updatePrintJobState(jobId:
string, state: PrintJobState, subState: PrintJobSu
bState): Promise<boolean>;
更新打印任务状态(promise形式)。
更新打印任务状态(promise形式)。
...
@@ -1454,8 +1798,9 @@ SystemCapability.Print.print
...
@@ -1454,8 +1798,9 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| jobId | number
| 是 | 打印任务Id。|
| jobId | string
| 是 | 打印任务Id。|
| state | [PrintJobState](#printJobState)| 是 | 打印任务状态。|
| state | [PrintJobState](#printJobState)| 是 | 打印任务状态。|
| subState | [PrintJobSubState](#printJobSubState)| 是 | 打印任务状态。|
**返回值:**
**返回值:**
...
@@ -1466,19 +1811,90 @@ SystemCapability.Print.print
...
@@ -1466,19 +1811,90 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let jobId = 3;
let jobId = '1002';
let printJobState = print.PrintJobState.PRINT_JOB_CREATED;
let printJobState = 1;
let printJobSubState =2;
print.updatePrintJobState(jobId, printJobState, printJobSubState).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## print.updateExtensionInfo
updateExtensionInfo(info: string, callback: AsyncCallback<boolean>): void;
更新扩展信息(callback形式)。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| info |string| 是 | 扩展信息。|
| callback | AsyncCallback<boolean> | 是 | 被指定的回调结果。 |
**示例:**
```js
let info = 'string';
print.updateExtensionInfo(info, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## print.updateExtensionInfo
updateExtensionInfo(info: string): Promise<boolean>;
print.updatePrintJobState(jobId,printJobState).then((data)=>{
更新扩展信息(promise形式)。
**需要权限:**
ohos.permission.MANAGE_PRINT_JOB
**系统能力**:
SystemCapability.Print.print
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| extensionId | string| 是 | 扩展ID。|
| info |string| 是 | 扩展信息。|
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise<boolean> | Promise形式返回执行结果。 |
**示例:**
```js
let info = 'string';
print.updateExtensionInfo(info).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
})
```
```
## print.
open
File
## print.
read
File
openFile(uri: string, callback: AsyncCallback<numb
er>): void;
readFile(config: ReadConfig, callback: AsyncCallback<ArrayBuff
er>): void;
打开文件(callback形式)。
打开文件(callback形式)。
...
@@ -1494,14 +1910,18 @@ SystemCapability.Print.print
...
@@ -1494,14 +1910,18 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
uri | string| 是 | 文件地址
。|
|
config | [ReadConfig](#readConfig)| 是 | 文件配置信息
。|
| callback |
AsyncCallback<number
> | 是 | 被指定的回调结果。 |
| callback |
AsyncCallback<Array<byte>
> | 是 | 被指定的回调结果。 |
**示例:**
**示例:**
```js
```js
let uri = '';
let readConfig = {
print.openFile(uri, (err, data) => {
file: '',
offset: 1,
max: 3,
}
print.readFile(readConfig, (err, data) => {
if (err) {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
return;
...
@@ -1509,9 +1929,9 @@ print.openFile(uri, (err, data) => {
...
@@ -1509,9 +1929,9 @@ print.openFile(uri, (err, data) => {
console.info('Operation successful. Data:' + JSON.stringify(data));
console.info('Operation successful. Data:' + JSON.stringify(data));
})
})
```
```
## print.
open
File
## print.
read
File
openFile(uri: string): Promise<numb
er>;
readFile(config: ReadConfig): Promise<ArrayBuff
er>;
打开文件(promise形式)。
打开文件(promise形式)。
...
@@ -1527,19 +1947,21 @@ SystemCapability.Print.print
...
@@ -1527,19 +1947,21 @@ SystemCapability.Print.print
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
uri | string| 是 | 文件地址
。|
|
config | [ReadConfig](#readConfig)| 是 | 文件配置信息
。|
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
Promise<number
> | Promise形式返回执行结果。 |
|
Promise<Array<byte>
> | Promise形式返回执行结果。 |
**示例:**
**示例:**
```js
```js
let uri = '';
let readConfig = {file: '';
print.openFile(uri).then((data)=>{
offset: 1,
max: 3,}
print.readFile(readConfig).then((data)=>{
console.info('Operation successful. Data: ' + JSON.stringify(data));
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
console.error('Operation failed. Cause: ' + JSON.stringify(error));
...
@@ -1574,25 +1996,23 @@ SystemCapability.Print.print
...
@@ -1574,25 +1996,23 @@ SystemCapability.Print.print
**示例:**
**示例:**
```js
```js
let files: Array<string> = ['./data/app/sample.pdf'];
print.PrintTask.on('block', () => {
print.print(files).then((task) => {
console.info("print task block")
task.on('blocked', () => {
console.info("print task blocked")
});
});
t
ask.on('success', () => {
print.PrintT
ask.on('success', () => {
console.info("print task success")
console.info("print task success")
});
});
task.on('failed
', () => {
print.PrintTask.on('fail
', () => {
console.info("print task fail
ed
")
console.info("print task fail")
});
});
task.on('cancelled
', () => {
print.PrintTask.on('cancel
', () => {
console.info("print task cancel
led
")
console.info("print task cancel")
});
});
});
```
```
## PrintTask.off
## PrintTask.off
off(type: 'blocked' | 'success' | 'failed' | 'cancelled', callback?: (
) => void): void;
off(type: 'blocked' | 'success' | 'failed' | 'cancelled', callback?: (boolean
) => void): void;
取消订阅打印任务状态变化事件。
取消订阅打印任务状态变化事件。
...
@@ -1614,21 +2034,19 @@ SystemCapability.Print.print
...
@@ -1614,21 +2034,19 @@ SystemCapability.Print.print
**示例:**
**示例:**
```
js
```
js
let
files
:
Array
<
string
>
=
[
'
./data/app/sample.pdf
'
];
print
.
PrintTask
.
off
(
'
block
'
,
()
=>
{
print
.
print
(
files
).
then
((
task
)
=>
{
console
.
info
(
"
print task block
"
)
task
.
off
(
'
blocked
'
,
()
=>
{
console
.
info
(
"
print task blocked
"
)
});
});
t
ask
.
off
(
'
success
'
,
()
=>
{
print
.
PrintT
ask
.
off
(
'
success
'
,
()
=>
{
console
.
info
(
"
print task success
"
)
console
.
info
(
"
print task success
"
)
});
});
task
.
off
(
'
failed
'
,
()
=>
{
print
.
PrintTask
.
off
(
'
fail
'
,
()
=>
{
console
.
info
(
"
print task fail
ed
"
)
console
.
info
(
"
print task fail
"
)
});
});
task
.
off
(
'
cancelled
'
,
()
=>
{
print
.
PrintTask
.
off
(
'
cancel
'
,
()
=>
{
console
.
info
(
"
print task cancel
led
"
)
console
.
info
(
"
print task cancel
"
)
});
});
});
```
```
## PrintMargin
## PrintMargin
...
@@ -1655,7 +2073,7 @@ print.print(files).then((task) => {
...
@@ -1655,7 +2073,7 @@ print.print(files).then((task) => {
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| startPage | 只读 | number | 是 | 开始页。 |
| startPage | 只读 | number | 是 | 开始页。 |
| endPage | 只读 | number | 是 | 结束页。 |
| endPage | 只读 | number | 是 | 结束页。 |
| pages | 只读 |
number
| 是 | 总页数。 |
| pages | 只读 |
Array<number>
| 是 | 总页数。 |
## PreviewAttribute
## PreviewAttribute
...
@@ -1676,7 +2094,7 @@ print.print(files).then((task) => {
...
@@ -1676,7 +2094,7 @@ print.print(files).then((task) => {
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| id | 只读 |
number
| 是 | 分辨率ID。
| id | 只读 |
string
| 是 | 分辨率ID。
| horizontalDpi | 只读 | number | 是 | 水平DPI。 |
| horizontalDpi | 只读 | number | 是 | 水平DPI。 |
| verticalDpi | 只读 | number | 是 | 垂直DPI。 |
| verticalDpi | 只读 | number | 是 | 垂直DPI。 |
...
@@ -1688,8 +2106,8 @@ print.print(files).then((task) => {
...
@@ -1688,8 +2106,8 @@ print.print(files).then((task) => {
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| id | 只读 |
number
| 是 | ID。
| id | 只读 |
string
| 是 | ID。
| name | 只读 |
number
| 是 | 名称。 |
| name | 只读 |
string
| 是 | 名称。 |
| width | 只读 | number | 是 | 宽度。 |
| width | 只读 | number | 是 | 宽度。 |
| height | 只读 | number | 是 | 高度。 |
| height | 只读 | number | 是 | 高度。 |
...
@@ -1714,12 +2132,13 @@ print.print(files).then((task) => {
...
@@ -1714,12 +2132,13 @@ print.print(files).then((task) => {
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| printerId | 只读 |
number
| 是 | 打印机id。 |
| printerId | 只读 |
string
| 是 | 打印机id。 |
| printerName | 只读 | string | 是 | 打印机名称。|
| printerName | 只读 | string | 是 | 打印机名称。|
| printerIcon | 只读 | number | 是 | 打印机按钮。|
| printerIcon | 只读 | number | 是 | 打印机按钮。|
| printerState | 只读 | [PrinterState](#PrinterState) | 是 | 打印机状态。
| printerState | 只读 | [PrinterState](#PrinterState) | 是 | 打印机状态。
| description | 只读 | string | 是 | 打印机描述。 |
| description | 只读 | string | 是 | 打印机描述。 |
| capability | 只读 | [PrinterCapability](#printerCapability) | 是 | 打印机能力。
| capability | 只读 | [PrinterCapability](#printerCapability) | 否 | 打印机能力。 |
| option | 只读 | string | 否 | json对象。 |
## PrintJob
## PrintJob
...
@@ -1735,12 +2154,13 @@ print.print(files).then((task) => {
...
@@ -1735,12 +2154,13 @@ print.print(files).then((task) => {
| jobState | 只读 | [PrintJobState](#printJobState) | 是 | 任务状态。
| jobState | 只读 | [PrintJobState](#printJobState) | 是 | 任务状态。
| copyNumber | 只读 | number | 是 | 打印份数。 |
| copyNumber | 只读 | number | 是 | 打印份数。 |
| pageRange | 只读 | [PrinterRange](#printerRange) | 是 | 打印范围。 |
| pageRange | 只读 | [PrinterRange](#printerRange) | 是 | 打印范围。 |
| isSequential | 只读 | boolean | 否 | 是否按顺序。 |
| isSequential | 只读 | boolean | 是 | 是否按顺序。 |
| pageSize | 只读 | [PrinterPageSize](#printerPageSize) | 否 | 纸张大小。 | isLandscape | 只读 | boolean | 否 | 是否垂直居中。 |
| pageSize | 只读 | [PrinterPageSize](#printerPageSize) | 是 | 纸张大小。 | isLandscape | 只读 | boolean | 是 | 是否垂直居中。 |
| colorMode | 只读 | number | 否 | 色彩模式。 |
| colorMode | 只读 | number | 是 | 色彩模式。 |
| duplexMode | 只读 | number | 否 | 双面模式。 |
| duplexMode | 只读 | number | 是 | 双面模式。 |
| margin | 只读 | [PrintMargin](#printMargin) | 否 | 打印边距。 |
| margin | 只读 | [PrintMargin](#printMargin) | 是 | 打印边距。 |
| preview | 只读 | [PreviewAttribute](#previewAttribute) | 否 | 预览设置。 |
| preview | 只读 | [PreviewAttribute](#previewAttribute) | 是 | 预览设置。 |
| option | 只读 | string | 否 | json对象。 |
## PrinterState
## PrinterState
...
@@ -1752,11 +2172,11 @@ print.print(files).then((task) => {
...
@@ -1752,11 +2172,11 @@ print.print(files).then((task) => {
| ------------------------------------ | ---------- | ---------------------------------------- |
| ------------------------------------ | ---------- | ---------------------------------------- |
| PRINTER_ADDED | 1 | 打印机添加。 |
| PRINTER_ADDED | 1 | 打印机添加。 |
| PRINTER_REMOVED | 2 | 打印机删除。 |
| PRINTER_REMOVED | 2 | 打印机删除。 |
| PRINTER_
IDLE | 3 | 打印机空闲。
|
| PRINTER_
UPDATE_CAP | 3 | 打印机更新。
|
| PRINTER_
PRINTING | 4 | 打印机打印中。
|
| PRINTER_
CONNECTED | 4 | 打印机已连接。
|
| PRINTER_
BLOCKED | 5 |打印机阻塞。
|
| PRINTER_
DISCONNECTED | 5 | 打印机断开连接。
|
| PRINTER_
BUSY | 6 | 打印机繁忙。
|
| PRINTER_
RUNNING | 6 |打印机运行终。
|
| PRINTER_
FAILED | 7 | 打印机故障|
| PRINTER_
UNKNOWN | 7 | 未知状态。 |
## PrintJobState
## PrintJobState
...
@@ -1766,13 +2186,63 @@ print.print(files).then((task) => {
...
@@ -1766,13 +2186,63 @@ print.print(files).then((task) => {
| 变量 | 值 | 说明 |
| 变量 | 值 | 说明 |
| ------------------------------------ | ---------- | ---------------------------------------- |
| ------------------------------------ | ---------- | ---------------------------------------- |
| PRINT_JOB_
CREATED | 1 | 打印任务创建
。 |
| PRINT_JOB_
PREPARE | 1 | 打印任务准备
。 |
| PRINT_JOB_QUEUED | 2 |
加入打印任务队列
。 |
| PRINT_JOB_QUEUED | 2 |
开始打印任务
。 |
| PRINT_JOB_
PRINT
ING | 3 | 打印任务执行中。 |
| PRINT_JOB_
RUNN
ING | 3 | 打印任务执行中。 |
| PRINT_JOB_BLOCKED | 4 | 打印任务阻塞。 |
| PRINT_JOB_BLOCKED | 4 | 打印任务阻塞。 |
| PRINT_JOB_SUCCESS | 5 | 打印任务成功。 |
| PRINT_JOB_COMPLETED | 5 | 打印任务完成。 |
| PRINT_JOB_FAILED | 6 | 打印任务失败。 |
| PRINT_JOB_UNKNOWN | 6 | 打印任务未知状态。|
| PRINT_JOB_cancelled | 7 | 打印任务取消。|
## PrintJobSubState
打印任务子状态枚举
**系统能力**:以下各项对应的系统能力均为SystemCapability.Print.print
| 变量 | 值 | 说明 |
| ------------------------------------ | ---------- | ---------------------------------------- |
| PRINT_JOB_SUCCESS | 0 | 打印任务成功。 |
| PRINT_JOB_FAILED | 1 | 打印任务失败。 |
| PRINT_JOB_CANCELLED | 2 | 打印任务取消。 |
| PRINT_JOB_FILE_CORRUPT | 3 | 已损坏。 |
| PRINT_JOB_BLOCK_OFFLINE | 4 | 打印任务离线。 |
| PRINT_JOB_BLOCK_BUSY | 5 | 打印任务繁忙。|
| PRINT_JOB_BLOCK_CANCELLED | 6 | 打印任务已取消。|
| PRINT_JOB_BLOCK_OUT_OF_PAPER | 7 | 用纸量不足。|
| PRINT_JOB_BLOCK_OUT_OF_INK | 8 | 墨水用完了。|
| PRINT_JOB_BLOCK_OUT_OF_TONER | 9 | 碳粉用完。|
| PRINT_JOB_BLOCK_JAMMED | 10 | 卡纸。|
| PRINT_JOB_BLOCK_DOOR_OPEN | 11 | 盖子打开。|
| PRINT_JOB_BLOCK_SERVICE_REQUEST | 12 | 服务请求。|
| PRINT_JOB_BLOCK_LOW_ON_INK | 13 | 墨水不足。|
| PRINT_JOB_BLOCK_LOW_ON_TONER | 14 | 碳粉不足。|
| PRINT_JOB_BLOCK_REALLY_LOW_ON_INK | 15 | 墨水太少。|
| PRINT_JOB_BLOCK_BAD_CERTIFICATE | 16 | 认证失败。|
| PRINT_JOB_BLOCK_UNKNOWN | 17 | 未知状态。|
## PrinterExtensionInfo
打印扩展信息,继承ExtensionAbilityInfo
**系统能力**:以下各项对应的系统能力均为SystemCapability.Print.print
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| extensionId | 只读 | string | 是 |打印机分机的扩展标识。 |
| vendorId | 只读 | string | 是 | 扩展的供应商id。|
| vendorName | 只读 | string | 是 | 供应商名称。|
| vendorIcon | 只读 | number | 是 | 供应商的资源id。|
| version | 只读 | string | 是 | 当前打印机扩展的版本。 |
## ReadConfig
文件配置
**系统能力**:以下各项对应的系统能力均为SystemCapability.Print.print
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| file | 只读 | string | 是 |文件地址。 |
| offset | 只读 | number | 否 | 偏移量。|
| max | 只读 | number | 否 | 最大偏移量。|
# PrintExtensionAbility
# PrintExtensionAbility
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录