问题描述
我正在关注用于集成的 git 演示示例:git : https://github.com/star-micronics/StarPRNT-SDK-iOS-Swift 我已经成功安装了 sdk,并且能够在 EnglishReceiptsImpl 类中打印样本。
现在,我正在尝试打印我在 api 响应中收到的内容。
我很担心:
我正在使用/为 TSP650II 打印机型号工作。
我安装的 Pod 是:
// Swift SDK 的 Pods
pod 'StarIO','2.8.2'
pod 'StarIO_Extension','1.15.0'
这是我的代码:
在 SearchPortViewController 类中
func openStarPrinter() {
var commands: Data
let localizeReceipts: ILocalizeReceipts = LocalizeReceipts.createLocalizeReceipts(AppDelegate.getSelectedLanguage(),paperSizeIndex: .threeInch)
// commands = PrinterFunctions.createTextReceiptData(emulation,localizeReceipts: localizeReceipts,utf8: false)
// Method (trying to print data from pdf url) : (createPdf417Data)
commands = ApiFunctions.createPdf417Data(emulation)
GlobalQueueManager.shared.serialQueue.async {
_ = Communication.sendCommands(commands,portName: self.portName,portSettings: self.portSettings,timeout: 10000,// 10000mS!!!
completionHandler: { (communicationResult: CommunicationResult) in
dispatchQueue.main.async {
self.showSimpleAlert(title: "Communication Result",message: Communication.getCommunicationResultMessage(communicationResult),buttonTitle: "OK",buttonStyle: .cancel)
// self.navigationController!.popViewController(animated: true)
}
})
}
}
ApiFunctions 类的位置
let globalPdfUrl:URL? = Bundle.main.url(forResource: "fake-store-receipt",withExtension: "pdf")
static func createPdf417Data(_ emulation: StarIoExtEmulation) -> Data {
let otherData = try! Data(contentsOf: globalPdfUrl!)
let builder: ISCBBuilder = StarIoExt.createCommandBuilder(emulation)
builder.beginDocument()
builder.appendPdf417Data(withAbsolutePosition: otherData,line: 0,column: 1,level: SCBPdf417Level.ECC0,module: 2,aspect: 2,position: 1)
builder.endDocument()
return builder.commands.copy() as! Data
}
但打印的格式不正确。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)