简体   繁体   中英

Local printers not visible from web application on EC2 Amazon( ubuntu)

We have a java-web application hosted on amazon ec2(ubuntu).

I'm unable to redirect my printing to the local default printers. In fact when i try to get a list of printers visible using the below code The only printer service that is listed on there is "PDF"

javax.print.PrintService[] service = (javax.print.PrintService[]) PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.AUTOSENSE, null)
        javax.print.PrintService service= null;
        for(javax.print.PrintService service1 : services){
            service = service1;
            System.out.println(service1.getName());
        }

Any suggestions/ tips is really appreciated.

You cannot do it in Java, since it's running on the server side, but you can do it in JavaScript in the browser.

Given that you want to print the whole web page, add HTML button "Print" that will call to JavaScript: window.print() .

Another option can be opening a pop-up, with window.print() called after the page is loaded. This can be useful, if you want to modify page's content before calling to print. For example removing the 'Print' button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM