quicktill
quicktill copied to clipboard
Logo support on printed receipts
The Cybar at EMF want to be able to print logos on receipts.
@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)
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.
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)
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.pycode, and then I've bodged in three lines toprinter.pyto load an SVG andprintimageit)
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).
Ah yes, something will have to rasterise the SVG to output it as esc/pos. Maybe easier to start with a PNG?
...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.
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.
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.