2

I'm working on an existing Java web application (HTML/CSS/JS/JSP/Servlets and Java classes in this particular app) that currently uses an applet to print checks.

My boss recently came to me and informed me that there are errors coming back on user's machines when testing the check printing against the latest versions of Java.

He is wondering how we could set up the application to print checks off without using an applet.

In the past, I've used Crystal Reports to lay out forms and print them but that was in asp.net.

I know there are Java PDF libraries available but I'm not at all familiar with any of them and not sure that they could be used to format and print checks in a Java web application.

So, I'm ultimately wanting to know about what has worked for those who have implemented check or form printing using Java/JSP/Servlets.

2012-02-24 @ 13:15EST edit
I mentioned "Java PDF libraries" above but have since found out that PDF cannot be used as end-users should not be able to save the check documents (unless PDF's can be made to not be saveable and just printable). All of the data is managed right on the database (Oracle in our case).

Zack Macomber
  • 6,682
  • 14
  • 57
  • 104
  • As it's about checks - do you have any non-functional requirements like archiving of the 'real' document and not only its data? – home Feb 24 '12 at 17:47
  • @home - I don't believe so but I'll need to confirm with my boss. Looking through the code, it doesn't look like the actual check documents are saved anywhere. – Zack Macomber Feb 24 '12 at 18:00
  • @home - just confirmed with him and the actual documents are not saved and also SHOULD NOT be saved - only printing of the documents can be allowed. The printing goes right onto check stock. – Zack Macomber Feb 24 '12 at 18:12

2 Answers2

2

I've used iText to create PDF files before for things like this. PDF is your answer, since the whole point of the format is that it never really changes. Much better than an Applet.

http://itextpdf.com/

Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108
  • Can iText be used to create non-saveable documents? Users should only be able to print the checks off and not store them on their computers... – Zack Macomber Feb 24 '12 at 18:44
  • 1
    The idea of something not savable is pretty crazy. If I take a camera, point it at the screen and take a picture, is that saving it? You mentioned it can be printed. What stops it from being printed to PDF? – Ryan Shillington Feb 24 '12 at 23:13
  • Why in this particular case the document shouldn't be savable and printable from PDF is that the user could print the check multiple times if the document was saved. Now, a savvy user could possibly take a print screen and then format it just right for printing but we're looking to make the form that the user prints from be just for printing. If there's no way of saving the document and a check gets printed multiple times, then the user will be to blame and will be reprimanded. If we allow the saving of the document natively and this happens, we'll be to blame... – Zack Macomber Feb 25 '12 at 00:59
  • Well, PDF does have all kinds of permissions stuff for this kind of thing. I never understood why anybody would care, but I guess you'll want to read up on it. – Ryan Shillington Feb 27 '12 at 02:43
0

I ended up digging deeper into using iText and came across flying-saucer which makes it super-easy to render a PDF from XML or XHTML.

Check it out at http://code.google.com/p/flying-saucer/

I also found out how to partially hide the save functionality by rendering the PDF inside a hidden iframe: Create a "print-only" PDF with itext

Community
  • 1
  • 1
Zack Macomber
  • 6,682
  • 14
  • 57
  • 104
  • I dont know how it can be implemented, but one can add watermark like "Sample" when the pdf is saved or printed without digital signatures – Jayy Mar 13 '12 at 05:34