- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我使用以下代码在 Epson TM-T20
上使用 Epson ePOS SDK for iOS
打印内容 SDK .问题是该应用程序只打印一次。该应用程序必须重新启动才能再次打印。代码有什么问题?
printer = Epos2Printer(printerSeries: 2, lang: 1)
printer?.setReceiveEventDelegate(self)
printer?.addText("text")
printer!.connect("TCP:192.168.1.185", timeout:Int(EPOS2_PARAM_DEFAULT))
printer!.beginTransaction()
printer?.sendData(Int(EPOS2_PARAM_DEFAULT))
printer?.endTransaction()
// printer?.disconnect()
printer?.clearCommandBuffer()
printer?.setReceiveEventDelegate(nil)
尽管在文档中使用过,但使用 printer?.disconnect()
会使应用程序卡住,所以我不得不将其注释掉。
如果您想查看 API 文档,里面有一个 PDF the SDK's download .
更新:根据答案更新代码(应用仍然卡住):
func printReceipt() {
var printer: Epos2Printer?
printer = Epos2Printer(printerSeries: 2, lang: 1)
if printer == nil {
print(“Printer not found!! 11")
}
printer?.setReceiveEventDelegate(self)
printer?.addTextFont(2)
printer?.addTextSize(1, height: 1)
printer?.addText(“My Text")
printer?.addFeedUnit(10)
printer?.addCut(0)
var result: Int = Int(EPOS2_SUCCESS.rawValue)
result = Int(printer!.connect("TCP:192.168.1.185", timeout:Int(EPOS2_PARAM_DEFAULT)));
result = Int(printer!.beginTransaction())
printer?.sendData(Int(EPOS2_PARAM_DEFAULT))
DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
printer?.clearCommandBuffer()
printer?.setReceiveEventDelegate(nil)
printer?.endTransaction()
printer?.disconnect()
printer = nil;
}
}
最佳答案
我有同样的问题,您必须实现 Epos2PtrReceiveDelegate 并使用 onPtrReceive 遵守其协议(protocol),并包括在该委托(delegate)内断开打印机。
示例如下:
希望对您有所帮助!
public func onPtrReceive(_ printerObj: Epos2Printer!, code: Int32, status: Epos2PrinterStatusInfo!, printJobId: String!) {
printerObj.endTransaction()
printerObj.disconnect()
printerObj.clearCommandBuffer()
printerObj.setReceiveEventDelegate(nil)
}
干杯!
关于iOS 仅使用 Epos2Printer 打印一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42154061/
我创建了一个 Delphi 服务,负责将 QuckReports 打印到 Printer.Printers 列表中包含的特定打印机。我将打印机名称传递给例程,然后它在 Printer.printers
powershell "get-content foo.txt|Out-Printer" 只要 foo.txt 是英文的,一切都很好(大部分情况下) 如果 foo.txt 包含 unicode 字符,
我将几个zpl文件发送到打印机进行测试,并且工作正常。 之后,我从UPS接收base64编码的zpl数据,并创建一个文件并通过Java小程序将其发送到打印机,现在我发送给它的任何zpl命令或文件都无济
我想在 ZPL 代码中注释行,例如: ^XA ^MMT ^LL0531 ^PW1280 ^LS0 ^FT81,528^A0B,29,28^FH\^FDTEXT^FS //
显然不是: use strict; use warnings; use Data::Printer; my @values = 1 .. 99; p @values[0..9]; 退货 10 docu
我使用 Zebra Designer 创建标签。但是我有一个问题来居中我的元素。 事实上,当我用 Zebra Designer 创建一个文本框时,它有一个固定的长度,当我替换里面的文本时(例如通过一个
我正在使用 Zebra MZ320 打印机来集成黑标。当黑标设置为True时,我面临问题。在纸张上遇到黑标后,打印机进纸2-3行 用于成功校准黑标的命令: ! DF CONFIG.SYS
我正在开发一个 chrome 应用程序,它需要经常与打印机通信,因此我将直接向打印机发送数据而无需打印对话框,因为该 chrome 提供 chrome.printerProvider API。但 ap
我刚刚修改了 Zebra 打印机的标签。我几乎完成了它,但我目前停留在第一行,我在多个站点上阅读了不同的主题,但没有任何帮助我得到我想要的东西。我们的标签是10cm高15cm宽,下面一行需要从中间到边
我知道这很容易解决,但我已经为此奋斗了一个小时。我需要不断从用户那里获取单词,直到他们输入“退出”并将其写入进程中的文件中。但问题是,它出现了“输入单词:”,但是当我输入它并按回车键时,它不会接受它,
我正在尝试在我的打印机 CANON MB5000 上使用 java print 打印一个文本文件。它适用于 Linux 但不适用于 Windows。在 Windows 上,这里支持文档风格: for
我想测试 IPP 应该具备的一些功能(即监控印象数;参见 this question),但我还没有得到硬件。我如何模拟这样的打印机?是否有虚拟 IPP 打印机的代码? 我将在 Linux 或 Wind
从标题可以看出,这个问题过去已经讨论过。我已将之前的帖子作为引用,并尝试在 Zebra 标签打印机上打印位图图像。我无法打印我正在寻找的图像。请不要忽略,因为它已经讨论过了。 请查看下面提到的代码片段
我正在使用 Crystal Reports 将订单打印到 KOT 打印机。我有四台不同的 KOT 打印机。根据分配的相应打印机名称打印项目。 这工作正常,但为了提高打印速度,我选中了“无打印机”选项。
我正在使用 Zebra GT800 标签打印机,标签角色大小为 2.5' * 1.75'。我正在努力使用 ZPL 命令将其调整为内部标签。我尝试使用在 ZPL 的用户指南中阅读的粗体文本中的几个值,但
我的客户端在使用旧的 Brother 打印机从 JAVA 应用程序打印时遇到问题。他得到的异常(exception)是“打印机不接受作业”。 其他应用程序(不是 java 应用程序)设法使用这些打印机
如何为“文本”添加换行符?比如说: Hello World 会变成 Hello World 无论如何,我可以为我的代码添加一个换行符吗? ^FT78,76^A0N,28,28^FH\^FDHello\
当执行powershell cmdlet Get-Printer时,我很好奇它从何处获取信息。它依靠WMI吗?它会解析注册表吗?我遇到过Get-Printer的响应不同于Windows设备和打印机控制
我正在将 ZPL 代码传递给 Zebra 打印机。在这个 ZPL 代码中,我有一部分会生成二维码。 QR 码的值来 self 在为 WM6.5 开发的移动应用程序中使用条形码扫描功能获得的字符串。扫描
我有一卷 5.1cm x 1.6cm(每行两个)的标签,我需要在每行上打印两个不同的标签(expected result),但是 ZPL 格式的打印命令只打印一个标签并送入下一个标签,将相邻的标签留空
我是一名优秀的程序员,十分优秀!