Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print image "data:image/png;base64,......" #71

Open
linhgfx opened this issue Jun 13, 2023 · 0 comments
Open

How to print image "data:image/png;base64,......" #71

linhgfx opened this issue Jun 13, 2023 · 0 comments

Comments

@linhgfx
Copy link

linhgfx commented Jun 13, 2023

Hi Kevin!

I have an image of the form "data:image/png;base64,..." .
How can I print it.
I converted it to a UIImage like this:

if let url = URL(string: imageBase64String) {
do {
let imageData = try Data(contentsOf: url)

guard let image = UIImage(data: imageData), let cgImage = image.cgImage else {
return
}
let receipt = Receipt(.🖨️58(.ascii))
<<~ .style(.initialize)
<<< Image(cgImage)

    if bluetoothPrinterManager.canPrint {
        bluetoothPrinterManager.write(Data(receipt.data))
    }
    
    dummyPrinter.write(Data(receipt.data))

      } catch {
          print(error)
       }
   }

but what i get is this :

IMG_20230613_111820

@linhgfx linhgfx changed the title How to print image How to print image "data:image/png;base64,......" Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant