我正在尝试从用于iOS的Nativescript + Vue应用程序中打印标签。我可以成功连接到打印机,但是当我尝试打印图像时,它将出现一个错误。我使用的打印机是“ QL-810W”。我加载的标签是62毫米卷(没有设置长度),可以同时支持红色和黑色。
这是周围的代码:
exports.BrotherPrinterClass = BrotherPrinterClass;
var BrotherPrinter = (function () {
function BrotherPrinter() {
}
BrotherPrinter.prototype.print_image = function (PrinterName, ipAddress, image) {
try {
let printer = new BRPtouchPrinter()
printer.printerName = PrinterName
printer.interface = CONNECTION_TYPE_WLAN
printer.setIPAddress(ipAddress)
let settings = new BRPtouchPrintInfo()
settings.strPaperName = "62mmRB"
settings.nPrintMode = 0x03 //PRINT_FIT_TO_PAGE
settings.nAutoCutFlag = 0x00000001 //OPTION_AUTOCUT
settings.nOrientation = 0x00 //ORI_LANDSCAPE
settings.nHorizontalAlign = 0x01 //ALIGN_CENTER
settings.nVerticalAlign = 0x01 //ALIGN_MIDDLE
printer.setPrintInfo(settings)
if (printer.startCommunication()) {
//Print to the printer
let errorCode = printer.printImageCopy(image.ios.CGImage, 1);
if (errorCode != 0)
console.log("ERROR - ", errorCode)
}
printer.endCommunication()
}
else{
console.log("Failed to connect")
}
}
catch(e) {
console.log("Error - ", e);
}
};
这将返回与“ ERROR_WRONG_LABEL_
”相关的错误“ -41”。我尝试过调整所有属性,也尝试过settings.strPaperName = "62mm"
,但这并没有返回任何不同的结果。
传入的图像是ImageSource类型,我还尝试了以下行let errorCode = printer.printImageCopy(image.ios, 1);
。这将返回错误代码0,它与ERROR_NONE_
相关,但是没有输出任何内容。据我所知,这不是SDK想要的CGImage。
我可以使用“ iPrint&Label”应用程序从iPad打印。只是不是来自SDK
编辑:
我尝试使用printFilesCopy()
从文件进行打印。当我打印时,这不会返回任何错误,但不会打印任何内容。另外,我可以错误地设置设置(例如,将'62mmRB'
更改为'102mm'
),也可以通过注释掉printer.setPrintInfo(settings)
行而完全不设置设置。这些更改不会影响结果。
此外,我购买了一个62毫米的仅黑色卷纸,并进行了尝试,结果发现我遇到了完全相同的问题。