sammy Posted May 19, 2008 Share Posted May 19, 2008 Hi All, I have a requirement to print reports generated by jasper reports to a network printer accessible by the server but not installed on the server. My code works fine if the network printer is installed on my server and also my code is able to list all the printers that are installed on the computer. But, once you delete the printer it doesn't work. Is there a way in jasper we can access network printer by giving the printer name like this "\ipaddressofcomputerprintername" ? Thanks! Link to comment Share on other sites More sharing options...
lshannon Posted May 19, 2008 Share Posted May 19, 2008 If have not worked with the printer API. But I am pretty sure it just wraps the Sun Print API:http://java.sun.com/j2se/1.4.2/docs/guide/jps/index.html I was just looking over the PrintServiceLookUp class:http://java.sun.com/j2se/1.4.2/docs/api/javax/print/PrintServiceLookup.html It looks like you can look up a PrintService based on DocFlavor and Attribute. One the types of Attributes is PrinterLocation: http://java.sun.com/j2se/1.4.2/docs/api/javax/print/attribute/standard/PrinterLocation.html Maybe you could use one of these attributes to locate the printer? Link to comment Share on other sites More sharing options...
sammy Posted May 20, 2008 Author Share Posted May 20, 2008 Hi, I used print service look up as given in the url. It works for the locally installed network printers. But, it doesn't work for the printers that are available on network and not installed on the computer. Thanks, Link to comment Share on other sites More sharing options...
dnvsrikanth Posted May 20, 2008 Share Posted May 20, 2008 Hi sammy, I also faced the same problem, I think its better to use Javascript for this. DNV Srikanth Link to comment Share on other sites More sharing options...
sammy Posted May 20, 2008 Author Share Posted May 20, 2008 Hi Srikanth, I tried java script for printing with the below code. It works fine for the default printer if I give code like this. javascript.append("this.print(false);"); It doesn't work if I specify the printer name like below. HashMap params = new HashMap();StringBuffer javascript = new StringBuffer();javascript.append("var params= this.getPrintParams();");javascript.append("params.interactive=params.constants.interactionLevel.silent;");javascript.append("params.pageHandling =params.constants.handling.shrink;");javascript.append("params.printername = \\ipaddress\printername;");javascript.append("this.print(params);"); Any ideas??? If you solved this problem using java script , Can you post the code sample? Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now