# 获取设备状态 getDeviceStatus
● 版本限制
3.0.2 +
● 接口函数
zwexplorer.ReceiptPrinter.getDeviceStatus
● 接口说明
获取凭条打印机当前的状态,是否缺纸等
● Typescript 类型参考
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.getDeviceStatus(data: {}, callback?: (res: ResBody)=>void): Promise<ResBody>
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,0 为正常,其它为异常 [状态码参考] |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.getDeviceStatus({},(res)=>{
// 返回数据
})
# 打印bmp图像base64 receiptPrintBmpBase64
● 接口函数
zwexplorer.ReceiptPrinter.receiptPrintBmpBase64
● 接口说明
将 1bit 色深的 bmp(位图)图片的base64数据,通过凭条打印机打印
额外说明
通过canvas等方式生成的base64默认为位深度为24(即24bit)的图像,
不能直接用于本接口的打印,
需要通过本插件的imageToBmp接口进行转换后才可以使用
● Typescript 类型参考
type ReqBody = {
bmpBase64: string,
}
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.receiptPrintBmpBase64(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
data.bmpBase64 | String | 是 | 需要打印的凭条图片的base64数据 |
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 0 正确返回,-1 错误返回 |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.receiptPrintBmpBase64({
bmpBase64: "/9j/4AAQSkZJRgABAQEASABIAAD/......",
},(res)=>{
// 返回数据
})
# 打印bmp图像文件 receiptPrintBmpFile
● 接口函数
zwexplorer.ReceiptPrinter.receiptPrintBmpFile
● 接口说明
将 1bit 色深的 bmp(位图)图片,通过凭条打印机打印
● Typescript 类型参考
type ReqBody = {
path: string,
portId?:number
}
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.receiptPrintBmpFile(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
data.path | String | 是 | 需要打印的凭条图片的地址 |
data.portId | String | 否 | 连接凭条打印机的 USB 接口 id |
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 0 正确返回,-1 错误返回 |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.receiptPrintBmpFile({
path: "D:/demo.bmp",
},(res)=>{
// 返回数据
})
# 文本打印 receiptPrintText
● 接口函数
zwexplorer.ReceiptPrinter.receiptPrintText
● 接口说明
通过文本行数据打印凭条
● Typescript 类型参考
type ReqBody = {
text: string,
portId?:number
}
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.receiptPrintText(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
data.text | String | 是 | 文本行数据 |
data.portId | String | 否 | 连接凭条打印机的 USB 接口 id |
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,0 为正常,其它为异常 [状态码参考] |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.receiptPrintText({
text: "测试文本",
},(res)=>{
// 返回数据
})
# xml数据打印 receiptPrintXml
● 接口函数
zwexplorer.ReceiptPrinter.receiptPrintXml
● 接口说明
通过 xml 数据打印凭条
● Typescript 类型参考
type ReqBody = {
xml: string,
portId?:number
}
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.receiptPrintXml(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
data.xml | String | 是 | xml 文本 |
data.portId | String | 否 | 连接凭条打印机的 USB 接口 id |
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,0 为正常,其它为异常 [状态码参考] |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.receiptPrintXml({
// 测试xml
xml:
'<?xml version="1.0" encoding="UTF-8"?>\n' +
'<Receipt>\n' +
' <!-- 进纸指定行数 -->\n' +
' <FeedLines>4</FeedLines>\n' +
' <!-- 文本行 -->\n' +
' <Text>打印图形测试</Text>\n' +
' <!-- 条形码 -->\n' +
' <Text>打印条形码测试</Text>\n' +
' <Barcode>\n' +
' <!-- 条形码字符内容打印位置 -->\n' +
' <!-- 0 - 不打印 -->\n' +
' <!-- 1 - 条码上方 -->\n' +
' <!-- 2 - 条码下方 -->\n' +
' <HRI>0</HRI>\n' +
' <!-- 条形码类型 -->\n' +
' <!-- 0 - EAN13 -->\n' +
' <!-- 1 - CODE39 -->\n' +
' <!-- 2 - CODE128 -->\n' +
' <Type>2</Type>\n' +
' <!-- 条形码宽度(一般设置为3) -->\n' +
' <Width>10</Width>\n' +
' <!-- 条形码高度(一般设置为168) -->\n' +
' <Height>4</Height>\n' +
' <!-- 条形码字符内容 -->\n' +
' <Content>0123456789</Content>\n' +
' </Barcode>\n' +
' <Text></Text>\n' +
' <Text>打印测试完成</Text>\n' +
' <!-- 打印设置,根据需求在打印文本、条形码和二维码之前进行设置 -->\n' +
' <Setting>\n' +
' <!-- 设置字体 -->\n' +
' <Font>\n' +
' <!-- 0 - 正常字体 -->\n' +
' <!-- 1 - 压缩字体 -->\n' +
' <Size>0</Size>\n' +
' <!-- true - 粗体 -->\n' +
' <!-- false - 正常 -->\n' +
' <Bold>false</Bold>\n' +
' <!-- true - 下划线 -->\n' +
' <!-- false - 正常 -->\n' +
' <UnderLine>false</UnderLine>\n' +
' <!-- true - 倍宽 -->\n' +
' <!-- false - 正常 -->\n' +
' <DoubleWidth>false</DoubleWidth>\n' +
' <!-- true - 倍高 -->\n' +
' <!-- false - 正常 -->\n' +
' <DoubleHeight>false</DoubleHeight>\n' +
' </Font>\n' +
' <!-- 设置字体大小 -->\n' +
' <FontSize>\n' +
' <!-- 1 - 正常 -->\n' +
' <!-- 2~7 - 放大倍数 -->\n' +
' <Width>1</Width>\n' +
' <!-- 1 - 正常 -->\n' +
' <!-- 2~7 - 放大倍数 -->\n' +
' <Height>1</Height>\n' +
' </FontSize>\n' +
' <!-- 设置粗体 -->\n' +
' <!-- true - 粗体 -->\n' +
' <!-- false - 正常 -->\n' +
' <FontBold>false</FontBold>\n' +
' <!-- 设置字符行高度,>=1 -->\n' +
' <LineSpace>1</LineSpace>\n' +
' <!-- 设置对齐方式 -->\n' +
' <!-- 0 - 左对齐 -->\n' +
' <!-- 1 - 居中 -->\n' +
' <!-- 2 - 右对齐 -->\n' +
' <AlignType>1</AlignType>\n' +
' <!-- 设置左边距,>=1 -->\n' +
' <LeftMargin>10</LeftMargin>\n' +
' <!-- 设置右边距,>=1 -->\n' +
' <RightMargin>10</RightMargin>\n' +
' <!-- 设置反白 -->\n' +
' <!-- true - 反白打印 -->\n' +
' <!-- false - 正常打印 -->\n' +
' <OppositeColor>false</OppositeColor>\n' +
' </Setting>\n' +
' <FeedLines>5</FeedLines>\n' +
' <!-- 切纸 -->\n' +
' <!-- 0 - 全切 -->\n' +
' <!-- 1 - 半切 -->\n' +
' <CutPaper>1</CutPaper>\n' +
'</Receipt>';
}, (res)=>{
// 返回数据
})
# 普通图转位图 imageToBmp
● 接口函数
zwexplorer.ReceiptPrinter.imageToBmp
● 接口说明
传入图片 base64 编码转换成位深为 1 的 base64 编码
● Typescript 类型参考
type ReqBody = {
base64: string,
}
type ResBody = {
resultCode: number, resultMessage: string, data: {}
}
zwexplorer.ReceiptPrinter.imageToBmp(data: ReqBody, callback?: (res: ResBody)=>void): Promise<ResBody>
● 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
data.base64 | String | 是 | 需要转换的图片的 base64 编码字符串 |
● 返回数据
参数 | 类型 | 必然存在 | 说明 |
---|---|---|---|
res.resultCode | Number | 是 | 状态码,0 为正常,其它为异常 [状态码参考] |
res.data | Object | 否 | 接口返回的详细数据 |
res.resultMessage | String | 否 | 接口消息 |
● 示例
zwexplorer.ReceiptPrinter.imageToBmp({
base64: "/9j/4AAQSkZJRgABAQEASABIAAD/......",
},(res)=>{
// 返回数据
})