CSP: Print All PDF Reports, Java Applet not Supported Anymore, How to Migrate to Java Web Start (JNLP)

Hi all-

We used to have this Java applet in our CSP page to "print all" and "download all" PDF medical reports.  We want this applet so that the user won't have to open each PDF in the browser just to print it.

But now most browsers do not support Java applets anymore due to security concerns, so that Java application is down.  We tried to migrate to Java Web Start but don't know how to invoke the JNLP file from the CSP page.  I am new to Cache so any help would be greatly appreciated.

Also, is there an easier solution to this print all problem?  I assume many hospitals/labs would be facing the same issue, so there might be a smart hack?

  • 0
  • 0
  • 359
  • 4
  • 2

Answers

Embedding a JLNP file in a CSP page is the same as in a plain HTML page. You have to embed and load the JLNP file using something like the following snippet:

 

<script src="https://www.java.com/js/deployJava.js"></script>
<script>
    var attributes = {} ;
    <!-- Base64 encoded string truncated below for readability -->
    var parameters = {jnlp_href: 'your_applet.jnlp',
        jnlp_embedded: 'PCEtLSANCi8qDQogKiBDb ... bmxwPg=='
    } ;
    deployJava.runApplet(attributes, parameters, '1.8');
</script>

 

In order to figure out the value for the jnlp_embedded parameter you have to base64 encode the contents of your JNLP file. The JNLP file has to be accessible from the relative link provided by the parameter jnlp_href.

This tutorial explains how to embed JNLP files:

http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/embe...

Thanks for the post Stefan

However, I have tried Firefox, Chrome, and IE.  All of them gave me error saying Java plug-in is not supported.

 

Is there a smarter way to do the printing job?

You can use pure javascript to do that:

function PrintAll() {
    var files = ["file1.pdf", "file2.pdf", "file3.pdf"];
    for (var i = 0; i < files.length; i++) {
        var newWindow = window.open(files[i], "print");
        newWindow.print();
        newWindow.close();
    }
}

Eduard,

Please correct me if I'm wrong.  Suppose I have 20 PDF reports to print, in this way I'd have to open 20 new windows viewing each PDF and select printer.  That doesn't sound very desirable.

I believe we had the Java applet to get us out from that situation.

Yes, there's no way to print multiple files from js with one dialogue.

You can merge all PDFs on server and print that.

I suppose you can also search for/develop browser extension to get around this particular feature of  browser security model, but that's probably more work than merging.

Comments

Thomas, I am working on the same problem.  I will post a solution if and when I get one.  And look for any support here to of course.