DRJTower
DRJTower

Reputation: 585

How to generate printable (and savable) forms with Java?

Here is my situation. I have written a Database application in Java. Now (unfortunately as an afterthought) I want to generate forms from data I pull from the database.

By form I mean a savable and printable file (not anything to do with UIs or swing). Basically I want to take a template form and fill in things from the data I pull from the database.

Is there any simple API for this? I really don't care about the file format, it just has to be savable and printable (pdf, word, open office, ect.). Forms have to be able to have differing fonts and possibly images though.

I looked at Apache POI for MS Word docs, and a few other APIs and these seem extremely painful.

Has anyone had a good experience with any particular API?

Thanks for your help!

Upvotes: 1

Views: 742

Answers (4)

DRJTower
DRJTower

Reputation: 585

Thanks for your help! I decided to go with a combination of iText and JXL (an Excel API).

Upvotes: 0

Jes
Jes

Reputation: 2778

I would recommend iText because it gives you the functionality of writing Graphics2D to the PDF canvas, which means you can easily embed images and such in your form.

A minor issue with the library is that the best examples, I believe, are in the "iText in action" book by Bruno Lowagie (ISBN: 1932394796), which costs around 50 dollars US.

iText can have a rather steep learning curve, but for forms and such it should be fairly easy. Another advantage is that it can be used in combination with e.g. JFreeChart.

If you only want to fill out already generated PDF forms, iText is the way to go, since it has some great abstractions for doing exactly that.

Upvotes: 1

Paul Jowett
Paul Jowett

Reputation: 6581

Docmosis is a good library as well for populating templates and outputting various formats. I have seen some places using both iText and Docmosis because each has strengths.

Upvotes: 0

Nikolaus Gradwohl
Nikolaus Gradwohl

Reputation: 20124

depending on your needs you can either use a reportgenerator like jasperreports or go for a pdf-library like iText

Upvotes: 4

Related Questions