Printing a pdf with javascript

Although i really like the IBM Content Navigator & Case Manager suites, its actually embarrassing that they lack a decent – out of the box – printing mechanism. For some reason they’re using a java applet to print jpg rendered documents to a printer, that in turn produce almost unreadable documents.

I’m not sure why they’re using 1. Java applets to print 2. pour quality documents, but it’s quite obvious there are way better mechanism’s to achieve a print.

My personal favorite: Do a back-end render to pdf, add a document.print() to the resulting PDF, and load that PDF in a hidden iframe.

This sample PDF was created using a java backend (using PDFBox) but i’m sure it’s comparable libraries are available for php, .net etc.

Now, as for the sample code:

The backend/java part:

The web/javascript part:

edited 28-02-2016 after Jeroen’s comment.

 

 

13 thoughts on “Printing a pdf with javascript

    1. Hi Amit,

      That’s a good idea, will do but i’m not sure when i’ll come to it. Will try to post it as a follow-up post on this one!

    1. Hi Amit,

      Did not have any time to spend on this yet. It’s high on my list, but i’m currently overbooked by my clients! Are you on a deadline? If so i could try to make some time for you. Additionally: what repository types are you using? P8?

  1. Hi Jonker,

    No I am not on a deadline but the problem is my end user are used to Chrome. So I am receiving complaints that just for Printing documents from Navigator they have to switch to IE. Even we requested IBM when we can have Print feature without Java dependency but it seems it will still take long time.

    And yes we are using FileNet P8.

    Thanks a lot for responding and hope to hear from you soon

  2. Hi Jonker,

    Tried creating a plugin but faced some issues while converting documents to PDF. Did you get any time to work on this?

    1. Hi Amit,

      Unfortunately i did not have any time yet! When converting documents, i think it’s probably easiest to reuse the out of the box /jaxrs/p8/getDocument. It’s quite a good service and only lacks support for a few key elements when it comes to office documents such as reviews and comments.

Leave a Reply

Your email address will not be published. Required fields are marked *