KevinGong2013 / Printer

Swift ticket printer framework for ESC/POS-compatible thermal printers.
Apache License 2.0
144 stars 72 forks source link

TicketImage not visible #48

Open mb812 opened 3 years ago

mb812 commented 3 years ago

I'm not able to print a 128x128 full black image (or any other image).

TicketImage code:

        Block.defaultFeedPoints = 30

        var ticket = Ticket()
        ticket.feedLinesOnTail = 3
        ticket.feedLinesOnHead = 0

        ticket.add(block: .image(UIImage(named: "black")!, attributes: TicketImage.PredefinedAttribute.alignment(.center)))
        ticket.add(block: .title("TEST"))
        ticket.add(block: .text(.init(content: "TEST", predefined: .alignment(.left))))
        ...

        ... print

Should this depend on the printer device? I'm using a GOOJPRT PT-210 thermal printer.

Everything else works great!

developerGM commented 3 years ago

@KevinGong2013 any news about this task?

burin-t commented 2 years ago

Check the scale of image (image.scale) or resize it to 1x scale and image width must mod 8 = 0

KevinGong2013 commented 1 year ago

Printer has been rewrite.

Please try this code.

let receipt = Receipt(.🖨️58(.ascii))
<<~ .style(.initialize)
 <<< Image(cgImage)
<<~ .page(.printAndFeed(lines: 1))