thomas_ramapuram Posted February 5, 2007 Share Posted February 5, 2007 Hi, Which would be a good mailing-list, Forum to report bugs on Jasper Reports/Cups? I thing there is a bug Printing Jasper Reports. I am not sure if the bug is in Jasper Report, Java Print API or CUPS but I'm sure there is a bug because, the same code works perfectly on Windows. It works with quirks on an earlier version of CUPS. But it does not work on the current version of CUPS. If this is the right forum. I could post all my code and the errors I get here. Regards, Thomas Ramapuram. Link to comment Share on other sites More sharing options...
citibob Posted August 7, 2007 Share Posted August 7, 2007 This is due to a known bug in Sun's Java print system that makes it not work with CUPS: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4900425 Consider the program at the bottom of this post (which is code taken out of JPPrintServiceExporter.java). When run on Linux (Fedora Core 6), it prints false twice, which means that it will never find the (properly installed) printers. When run on Mac OS X Tiger (which also uses CUPS), it prints false the first time, but true the second. Workarounds: 1. On Mac OS X, run the code snipped down below once at the start of your application. This should work, but I haven't tried it yet. 2. For Linux, modify JPPrintServiceExporter.checkAvailablePrinters() to always return true on Linux. This will required using a modified version of JasperReports, of course. :-( Hope this helps.-- Bob import javax.print.*;import javax.print.attribute.*;import javax.print.attribute.standard.*; public class PrintersTest{ // artf1936 public static boolean checkAvailablePrinters() { PrintService[] ss = java.awt.print.PrinterJob.lookupPrintServices(); for (int i=0;i<ss.length;i++) { Attribute[] att = ss.getAttributes().toArray(); for (int j=0;j<att.length;j++) { if (att[j].equals(PrinterIsAcceptingJobs.ACCEPTING_JOBS)) { return true; } } } return false; } public static void main(String[] args) { System.out.println(checkAvailablePrinters()); System.out.println(checkAvailablePrinters()); }} Link to comment Share on other sites More sharing options...
dll Posted December 1, 2007 Share Posted December 1, 2007 The Sun bug you mention is closed. I've also run the test-code on Linux (Ubuntu "F" with Sun Java 1.5.0_09-b03) and it does not produce the error you describe. 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