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

Logo support on printed receipts #156

Closed
sde1000 opened this issue Jul 6, 2018 · 8 comments · Fixed by #282
Closed

Logo support on printed receipts #156

sde1000 opened this issue Jul 6, 2018 · 8 comments · Fixed by #282

Comments

@sde1000
Copy link
Owner

sde1000 commented Jul 6, 2018

The Cybar at EMF want to be able to print logos on receipts.

@sde1000 sde1000 added this to the EMF 2018 milestone Jul 6, 2018
@sde1000 sde1000 removed this from the EMF 2020 milestone May 22, 2020
@jayaddison
Copy link
Contributor

@sde1000 I attempted this yesterday evening and managed to get something working by using svglib to read an SVG image and convert it to a reportlab format suitable for the existing printimage method.

Testing that as PDF-to-window-from-till required a small adjustment to the pdrivers.pdf_printer.process_canvas code around here.

Should the other printer drivers 'just work', or is PDF a special-case? And in either case: should I follow-up with a pull request? (I'll check with some EMF folks whether it's OK to use the EMF 2024 logo before that if so, to be on the safe side)

@sde1000
Copy link
Owner Author

sde1000 commented Apr 13, 2024

They are all "special-case", unfortunately — although at the moment PDF and ESC/POS are the only two cases.

Are you converting to a PIL Image to send into reportlab? If so, that's a good step towards working with ESC/POS — there is suitable code in python-escpos which I currently don't depend on but possibly ought to.

@jayaddison
Copy link
Contributor

They are all "special-case", unfortunately — although at the moment PDF and ESC/POS are the only two cases.

Ok. Drats :)

Are you converting to a PIL Image to send into reportlab? If so, that's a good step towards working with ESC/POS — there is suitable code in python-escpos which I currently don't depend on but possibly ought to.

I'm not sure, to be honest - it's possible that PIL is involved somewhere; as far as I can tell though, svglib reads the input SVG as XML and then renders a reportlab-format Drawing object directly.

It's possible that my plan to read the native SVG logo as input is making this more complicated than it needs to be; even so, the code for the PDF implementation is fairly minimal (2 lines of pdrivers.py code, and then I've bodged in three lines to printer.py to load an SVG and printimage it)

@jayaddison
Copy link
Contributor

It's possible that my plan to read the native SVG logo as input is making this more complicated than it needs to be; even so, the code for the PDF implementation is fairly minimal (2 lines of pdrivers.py code, and then I've bodged in three lines to printer.py to load an SVG and printimage it)

Although that makes it sound easy: alignment/formatting is also required to make this look sensible, and I haven't implemented anything to do that yet (currently studying the text-based alignment code).

@sde1000
Copy link
Owner Author

sde1000 commented Apr 13, 2024

Ah yes, something will have to rasterise the SVG to output it as esc/pos. Maybe easier to start with a PNG?

@jayaddison
Copy link
Contributor

...or perhaps even BMP?

I've learned of the existence of escpos-tools, some PHP code that can translate ESCPOS output into HTML, including images.

So now I'm thinking about trying to borrow and adapt some of the existing emulated QR raster code to handle black-and-white bitmap images.

@sde1000
Copy link
Owner Author

sde1000 commented Apr 29, 2024

That could work!

It would probably be simpler than the existing raster QR printing code — that does its own interleaving to get a good quality print on a dot-matrix printer. Printing an image on a thermal printer doesn't need that.

@jayaddison
Copy link
Contributor

While developing #282 I noticed in the Epson ESC/P reference docs (I think Epson own the epson.biz domain in that URL; double-check if cautious) that there is an FS ( E command that, if I understand it correctly, can configure printing of a logo from the nonvolatile storage of some printer models. I've opted to re-use the existing generic image rendering commands instead so far, but thought it'd be worth mentioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants