Hi, I assumed that when I run PrintServiceLookup.lookupDefaultPrintService() in a browser I get the printers from the machine where the browser is running. Alas I get the printers from the machine where Tomcat is running.
Is there a way get the local printers and print something to a local printer? I’d like to print a label directly to a printer.
PS I tried to use this to get the local default printer:
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
if (ps != null)
btnPrinter.setCaption(ps.getName());
Hi,
The code of screen controllers runs on the server, not in the web browser.
So this code doesn’t work as you expect.
Also, web browsers give very little control to any web application regarding printing web content.
See: JavaScript Output
JavaScript does not have any print object or print methods.
You cannot access output devices from JavaScript.
The only exception is that you can call the window.print() method in the browser to print the content of the current window.