Open ajay-pal-singh opened 5 years ago
Upload your demo image here. Is it jpg image you want to print? What is image size? Height x width of image ?
It is the same image that is in example of project with name demo.png
try code
let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 1 let imgblock = ImageBlock(img, attributes: [ImageBlock.PredefinedAttribute.alignment(.center)]) receipt.add(block: imgblock) for datas in receipt.datas { let sendtest = self.client.send(data: datas as NSData) print("send data: \(sendtest)") }
let me know what does it do
Image is work to me , but .qr only print string not QRcode, any one know how to make image printing alignment in center or print rectangle image
Try converting qr to image, then print
Try converting qr to image, then print
thanks. i will try..
let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 1 let imgblock = ImageBlock(img, attributes: [ImageBlock.PredefinedAttribute.alignment(.center)]) receipt.add(block: imgblock) for datas in receipt.datas { let sendtest = self.client.send(data: datas as NSData) print("send data: (sendtest)") }
It shows errors on these lines >
let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 1 let imgblock = ImageBlock(img, attributes: [ImageBlock.PredefinedAttribute.alignment(.center)]) receipt.add(block: imgblock) for datas in receipt.datas { let sendtest = self.client.send(data: datas as NSData) print("send data: (sendtest)") }
It shows errors on these lines >
- receipt.add(block: imgblock) >>>> Cannot convert value of type 'ImageBlock' to expected argument type 'Block'
- for datas in receipt.data >>>> Type '(String.Encoding) -> [Data]' does not conform to protocol 'Sequence'
try let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 2 receipt.add(block: Block.image(img, attributes [ImageBlock.PredefinedAttribute.alignment(.center)])) pm.print(receipt)
let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 1 let imgblock = ImageBlock(img, attributes: [ImageBlock.PredefinedAttribute.alignment(.center)]) receipt.add(block: imgblock) for datas in receipt.datas { let sendtest = self.client.send(data: datas as NSData) print("send data: (sendtest)") }
It shows errors on these lines >
- receipt.add(block: imgblock) >>>> Cannot convert value of type 'ImageBlock' to expected argument type 'Block'
- for datas in receipt.data >>>> Type '(String.Encoding) -> [Data]' does not conform to protocol 'Sequence'
try let img = UIImage(named: "demo")! var receipt = Receipt() receipt.feedLinesOnTail = 2 receipt.add(block: Block.image(img, attributes [ImageBlock.PredefinedAttribute.alignment(.center)])) pm.print(receipt)
Unfortunately same result, it just print 20% of image and then blank
@DhanjuAjay can you solved printing image issue?
@DhanjuAjay can you solved printing image issue?
Still not solved, even the example app is just printing title, then stop working.
@DhanjuAjay which thermal printer are you using? Have you tried another thermal receipt printer. It works on ESC/POS printers
Try 80mm thermal receipt printer from eBay will do the job
@DhanjuAjay which thermal printer are you using? Have you tried another thermal receipt printer. It works on ESC/POS printers
Try 80mm thermal receipt printer from eBay will do the job
I am using this printer:
Not working for me
https://www.ebay.co.uk/c/1874761593 2017 WiFi POS Wireless Thermal Receipt Printer 80mm Auto ...
Successfully tested and working on these printers
Thanks for information, is there any way to Print from my printer ?
I think your printer is for label printing. I haven't tested my code on label printer.
I'm sure image will print, if you try print on 80mm receipt printer, is mainly used in epos receipt printing.
I think your printer is for label printing. I haven't tested my code on label printer.
I'm sure image will print, if you try print on 80mm receipt printer, is mainly used in epos receipt printing.
I have printer this print from android app, and printer works perfectly with an android library, but not with iOS library 😔
Hello , I have tested the latest example, now alignment is not working, initially example was working fine for text only
I am encountering the same issue, it just prints blank spaces. It even crashes sometimes. Is there a specific dimension for the images?
Print only square logo image. Try one of 32x32 px, 64x64, 128x128, 256x256. If your image is not any of these size than resize programmatically before give it to printer's receipt object.
@pylearndl I download your fork and run the sample project, the image is 40x40 so I resized it to 32x32, still it doesn't work. It will just print blank spaces. Did you test your fork on a real device?
Send me screenshot and error, what printer you using? My all deployed ios apps are working on wifi 80mm thermal printer just fine. Kevins' code wasn't working initially when I tried to integrate. I made my code to make it work and fork in his git to let others to use it.
@pylearndl thanks for the quick reply. Here is my printer specs
No error is logged to the console. The printer slightly prints a blank line. That's all my observation.
What printer you using? Send me image
I can see you trying to print on 58mm printer. Unfortunately I m not sure about it. I have tested and it's working absolutely fine on 80mm thermal receipt printers.
https://www.ebay.co.uk/c/1874761593 2017 WiFi POS Wireless Thermal Receipt Printer 80mm Auto ...
I sent you this link to see the printer ios code works. I haven't tested on any other thermal printers
@pylearndl it might be the problem of printer model. As I'm making a receipt printing app for a small business, a 80mm printer is way too big. I will wait for upcoming updates, for now I'm happy printing the logo as a large text. Thank you for your time 👍
Kevin has updated his code on GitHub with new version. You should try and see if it works for your 58mm printer. Just give it a go
I'm also can't print image on 58mm printer
Printer
has been rewrite.
select Mode
to double width& double height
let receipt = Receipt(.🖨️58(.ascii))
<<~ .style(.initialize)
<<< Image(cgImage, mode: .doubleWH)
<<~ .page(.printAndFeed(lines: 1))
Image(cgImage, mode: .doubleWH) is key code.
@pylearndl how to print non-square image?
guard let image = UIImage(named: "demo") else { return }
I am using above code to print image and Qr code but it shows error while printing, As Shown in image