2004 IR Help Posted August 24, 2006 Share Posted August 24, 2006 By: Dave G - dgarratt Jasper does not pick up default printer chnge 2005-10-31 14:52 I have a method within my application to change the windows default printer. It works as I've tested it by printing from other applications after using it within my java app. However jasper appears to get the default printer once and remember it. Is there any way to force jasper to look again as I've spent a long time trying to provide the user a way of changing the default within the previewer. Many thanks. Dave Link to comment Share on other sites More sharing options...
Smig Posted April 30, 2008 Share Posted April 30, 2008 I've got a somewhat similar situation. In my case, printing directly to the default printer without the print dialog usually fails to get the right default printer within windows. This happens in cases where the default printer changed in the OS or if another application used another printer with some dialog (without setting them as default). What's strange is that restarting the java app doens't seem to resolve the issue so this could also be a problem with the JVM and the information it keeps about printers. Is there a way to force jasper to fetch the default printer again just before printing? Link to comment Share on other sites More sharing options...
Smig Posted April 30, 2008 Share Posted April 30, 2008 Actually, I've ended up solving this issue. If there's anyone else facing this problem here's what I did. I simply added those 2 lines of code: Code: PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService(); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, defaultPrintService); One fetches the default printer and the other passes that as an export parameter to JRPrintServiceExporter. I don't know why it doesn't work as it should without these lines, it seems like the way jasper chooses the default printer is a bit buggy. Everything is working as expected now. Link to comment Share on other sites More sharing options...
lucianc Posted April 30, 2008 Share Posted April 30, 2008 Smig wrote:I don't know why it doesn't work as it should without these lines, it seems like the way jasper chooses the default printer is a bit buggy. JRPrintServiceExporter does not use the default print service, but the first print service returned by PrintServiceLookup.lookupPrintServices(DocFlavor, AttributeSet). If you think this is a bug, please log it here. Regards,Lucian 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