更新记录

v1.0.0(2024-07-05) 下载此版本

UNIPHIZ系统打印机设备控制插件


平台兼容性

Android Android CPU类型 iOS
适用版本区间:5.0 - 14.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


UNIPHIZ-API-Printer Specification

To use this plugin, you also need to install the UNIPHIZ-API-Common plugin, otherwise some functions may not work properly

1. Reference Mode

const printer = uni.requireNativePlugin('UNIPHIZ-API-Printer-PrintManager')

2. Interface Catalog

// Get instance

init()

// Release resource

destroy()

// Cut a paper

cutPaper(mode)

// Perform label gap paper learning

detectPaper()

// Enumerate the fonts supported by the current device

enumFontsSupported(maxFontNum)

// Get the paper cutting modes supported by the machine

getCutMode()

// Get the current number of dot matrix lines printed

getDotLine()

// Read the print matrix of the specified character

getFontDot(fontSize, str)

// Get the printing mode.

getPrintMode()

// Query the current printing status

getPrintStatus()

// Get printer temperature

getTemperature()

// Move the printer forward or backward by the specified number of pixels

movePaper(pix)

// Print a image by file's data encoded in Base64

printImageByData(imageData)

// Print a image by file's data encoded in base64

printImageByDataAtGrayThreshold(imageData, grayThreshold)

// Print a image by file's path

printImageByPath(imagePath)

// Print a image by file's path

printImageByPathAtGrayThreshold(imagePath, grayThreshold)

// Print string

printStr(str, charset)

// Select the printer font

parameter with 1 - Font attributes for half-width character font (e.g., English, Russian, etc.)

parameter with 2 - Font attributes for full-width character font (e.g., Chinese, Japanese, etc.)

selectFont(charSet1, width1, height1, bold1, italic1, charSet2, width2, height2, bold2, italic2)

// Set the paper cutting mode to cut the paper immediately after printing

Note: Please call this function before calling prnStart()

setCutPaperMode(mode)

// Set the printing font height, enabling double-height printing on the basic font

setDoubleHeight(redoubleHalfWidthChar, redoubleFullWidthChar)

// Set the printing font width, enabling double-width printing on the basic font

setDoubleWidth(redoubleHalfWidthChar, redoubleFullWidthChar)

// Set the printer font name

setFontName(name)

// Set the font for printing

setFontSize(halfWidthCharCode, fullWidthCharCode)

// Set the printing grayscale level

setGrayscale(level)

// Set the label paper size

setLabelBoundary(height, width)

// Set the left margin for character printing

setLeftIndent(indent)

// Set the printing mode

setPrintMode(mode)

// Set reverse printing

setReversePrint(reverse)

// Set the printing character spacing and line spacing

setSpacing(charSpace, lineSpace)

// Open the printer and print the data from the buffer

For proper usage, follow the formula: Dots per line = Character height + Line spacing

Total dots = Dots per line * Number of lines [Total dots should be less than 3000, Default character height is 24]

startPrint()

3. Interface Specification

init() / initByContext()

Function Description

Function Type Description
function get instance

Example

printer.init()   // initByContext()

destroy()

Function Description

Function Type Description
function release resource

Example

printer.destroy()

cutPaper(mode)

Function Description

Function Type Description
json result of execution
Parameter Type Description
mode number cut-mode of device

Example

printer.cutPaper(1)

detectPaper()

Function Description

Function Type Description
json result of execution

Example

printer.detectPaper()

enumFontsSupported(maxFontNum)

Function Description

Function Type Description
json fonts supported by the current device
Parameter Type Description
maxFontNum number maximum number of fonts that the Fonts buffer can hold(0-64)

Example

const result = printer.enumFontsSupported(8)

getCutMode()

Function Description

Function Type Description
json paper cutting modes supported by the machine

Example

const modes = printer.getCutMode()

getDotLine()

Function Description

Function Type Description
json number of dot matrix lines printed

Example

const result = printer.getDotLine()

getFontDot(fontSize, str)

Function Description

Function Type Description
json result of execution
Parameter Type Description
fontSize number 0: smaller, 1: larger
str string the specified character

Example

const result = printer.getFontDot(0, "gb2312")

getPrintMode()

Function Description

Function Type Description
json mode of printing

Example

const result = printer.getPrintMode()

getPrintStatus()

Function Description

Function Type Description
json status of printing

Example

const result = printer.getPrintStatus()

getTemperature()

Function Description

Function Type Description
json temperature of printer

Example

const result = printer.getTemperature()

movePaper(pix)

Function Description

Function Type Description
json result of execution
Parameter Type Description
pix number number of pixels to move forward or backward

Example

const result = printer.movePaper(20)

printImageByData(imageData)

Function Description

Function Type Description
json result of execution
Parameter Type Description
imageData string image data in base64

Example

const result = printer.printImageByData("GIUYGBUKYgfufUTFUGYFVYUFYTDFYG ... ")

printImageByDataAtGrayThreshold(imageData, grayThreshold)

Function Description

Function Type Description
json result of execution
Parameter Type Description
imageData string image data encoded in base64
grayThreshold number grayThreshold

Example

const result = printer.printImageByDataAtGrayThreshold("GIUYGBUKYgfufUTFUGYFVYUFYTDFYG ... ", 60)

printImageByPath(imagePath)

Function Description

Function Type Description
json result of execution
Parameter Type Description
imagePath string image's path

Example

const result = printer.printImageByPath("/storage/emulated/0/Download/image.JPG")

printImageByPathAtGrayThreshold(imagePath, grayThreshold)

Function Description

Function Type Description
json result of execution
Parameter Type Description
imagePath string image's path
grayThreshold number grayThreshold

Example

const result = printer.printImageByPathAtGrayThreshold("/storage/emulated/0/Download/image.JPG", 60)

printStr(str, charset)

Function Description

Function Type Description
json result of execution
Parameter Type Description
str string string to be print
charset string result of execution

Example

const result = printer.printStr("Data to be print ...", "GB2312")

setCutPaperMode(mode)

Function Description

Function Type Description
json result of execution
Parameter Type Description
mode number mode of paper cutting

Example

const result = printer.setCutPaperMode(1)

setDoubleHeight(redoubleHalfWidthChar, redoubleFullWidthChar)

Function Description

Function Type Description
json result of execution
Parameter Type Description
redoubleHalfWidthChar number whether redouble half-width character's height
redoubleFullWidthChar number whether redouble full-width character's height

Example

const result = printer.setDoubleHeight(0, 0)

setDoubleWidth(redoubleHalfWidthChar, redoubleFullWidthChar)

Function Description

Function Type Description
json result of execution
Parameter Type Description
redoubleHalfWidthChar number whether redouble half-width character's width
redoubleFullWidthChar number whether redouble full-width character's width

Example

const result = printer.setDoubleWidth(0, 0)

setFontName(name)

Function Description

Function Type Description
json result of execution
Parameter Type Description
name string font's name

setFontSize(halfWidthCharCode, fullWidthCharCode)

Function Description

Function Type Description
json result of execution
Parameter Type Description
halfWidthCharCode number font size of half-width character
fullWidthCharCode number font size of full-width character

Example

const result = printer.setFontSize(1,1)

setGrayscale(level)

Function Description

Function Type Description
json result of execution
Parameter Type Description
level number level of grayscale

Example

const result = printer.setGrayscale(1)

setLabelBoundary(height, width)

Function Description

Function Type Description
json result of execution
Parameter Type Description
height number height of the label paper in millimeters
width number width of the label paper in millimeters

Example

const result = printer.setLabelBoundary(10, 10)

setLeftIndent(indent)

Function Description

Function Type Description
json result of execution
Parameter Type Description
indent number left indent

Example

const result = printer.setLeftIndent(20)

setPrintMode(mode)

Function Description

Function Type Description
json result of execution
Parameter Type Description
mode number print mode

Example

const result = printer.setPrintMode(0)

setReversePrint(reverse)

Function Description

Function Type Description
json result of execution
Parameter Type Description
reverse number reverse printing code

Example

const result = printer.setReversePrint(0)

setSpacing(charSpace, lineSpace)

Function Description

Function Type Description
json result of execution
Parameter Type Description
charSpace number Character spacing [in pixels]
lineSpace number Line spaceing [in pixels]

Example

const result = printer.setSpacing(10, 15)

startPrint()

Function Description

Function Type Description
json result of execution

Example

const result = printer.startPrint()

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

作者未提供license.md

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问