Swift ticket printer framework for ESC/POS-compatible thermal printers
Printer is available on CocoaPods. Simply add the following line to your podfile:
# For latest release in cocoapods
pod 'Printer', :git => 'https://github.com/KevinGong2013/Printer.git', :branch => 'refactor'
import Printer
let receipt = Receipt(.🖨️58(.ascii))
<<~ .style(.initialize)
<<< Image(cgImage)
<<< "Testing"
<<< "Testing"
<<< KV("k", "v")
<<~ .style(.clear)
<<< Image(cgImage, grayThreshold: 28)
<<< Dividing.`default`()
<<~ .page(.printAndFeed(lines: 0))
<<~ .style(.initialize)
<<< QRCode(content: "https://www.apple.com")
<<~ .style(.underlineMode(.enable2dot))
<<~ .page(.printAndFeed(lines: 10))
printer.write(Data(receipt.data))
// connect your pirnter&print ticket.
private let bluetoothPrinterManager = BluetoothPrinterManager()
private let dummyPrinter = DummyPrinter()
if bluetoothPrinterManager.canPrint {
bluetoothPrinterManager.write(ticket)
}
dummyPrinter.write(ticket)
[TODO]
link |
Stars: 128 |
Last commit: 4 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics