Sometimes I use https://printjs.crabbly.com/ - after writing solutions by my own I changed to this because it is a nightmare to maintain it with wide browser support. In my opinion this lib is the most complete. Possibly you can adopt it in “custom.js” to consum the print action from sao.
In other environments (f.e. a browser solution for shipment handling with label printers) I us a simple printserver that consumes base64-data and call it via link or ajax
import cherrypy
from ezprinting import PrintJob
import base64
class PrintServer(object):
@cherrypy.expose
def index(self, printer_name, data):
"""
printer names submitted should be known or you can rename them in cups
or fix it with something like:
if printer_name == 'label':
printer_name = 'robotron_nadeldrucker_1234'
else:
printer_name = 'veb_blaupause_KYB'
"""
if not data:
return
try:
content = base64.urlsafe_b64decode(data)
except Exception as e:
return str(e)
pjob = PrintJob.new_cups(printer_name=printer_name, content=content)
result = pjob.print()
return result
if __name__ == '__main__':
conf = {
'/': {
'tools.response_headers.on': True,
'tools.response_headers.headers': [
('Access-Control-Allow-Origin', '*')],
'server.socket_port': 8080
}
}
cherrypy.quickstart(PrintServer(), '/', conf)