Silent printing on clients printer for a hospital front desk ADF project

1.1k Views Asked by At

I am working on a Hospital front desk ADF project, here I need to generate visit slips these dont require print preview.I want to get to print the slips without any print dialogs nor do I want a popup window. I tried lot of stuff found on the net but nothing solid has come up.. Tried this.print on the Jasper report, tried the same through Java but I am getting dialog. I am working on an intranet so the security aspect is out of the discussion so how so I make this work?

3

There are 3 best solutions below

0
On BEST ANSWER

Well I found out a way to do this..

JRPdfExporter exporter = new JRPdfExporter();
        exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,
                              "var pp = this.getPrintParams();pp.interactive=pp.constants.interactionLevel.silent;pp.NumCopies=1; this.disclosed= true ;this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:pp});");

This adds pdf javascript to the generated pdf.. Once the pdf is displayed on the popup page it performs the silent print.. Hope this helps someone in the future..

0
On

This is a suggestion rather than an answer, but I can't write comments before I get 50 points of reputation - maybe one of these will help:

  1. Printing an html file using java without showing print dialog to the user

  2. How would I suppress the print dialog in this example?

0
On

I was able to perform the silent print, I used a popup window to call a servlet which generated the required visit slip and displayd the same on the pop window. For the silent print I used

                exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:this.getPrintParams().constants.interactionLevel.silent});this.close();");

I had to make a couple of changes to IE, I added my url to the trusted site option in IE. I enabled js in acrobat and also pointed acrobat to the trusted sites in IE. This resolved silent print but am stuck with another issue..

I am not being able to close the window once print is done.. I tried this..

            "var win = window.open('PrintPopUp.jsf','_blank',\"height=300,width=200,scrollbars=no," +
        "status=no, resizable=no, screenx=0, screeny=0\");win.onclick=function(){setTimeout(function(){win.close();\n},9000);}

But its not working in IE 11.. any suggestions?