Monday, August 18, 2008

PDF creation with Java

Adobe's PDF is the web's favorite document format. Word doc? It may not open correctly from your Mac and it seems too clumsy because it can contain too many Microsoft propreitary things. Even the IRS takes PDF generated from Tax software. Everyone loves the PDFviewer where you can zoom, find, print with ease.

Java can create PDF files. One way is via open-source library known as iText. This neat library allows you to create PDF from scratch or insert stuff to it. PDF files can actually handle form data too. It can be used to merge your text into fields. Just 1 jar, fairly easy to use. Great tool.

Of course, people would demand more. Business apps loves reports, pie charts! Of course, you can generate your reports easily on a web page. But can you save it, zoom into it or page up and down quickly like PDF files? Traditionally, people generate great looking reports with things like Crystal Reports: drag-and-drop fields, put header and footer, and voila. You can do that with Java and JasperReport.

Instead of drag-and-drop fields in WSYIWIG, JasperReport wants you to specify a report in their XML, and then plug into your datasource. Anyone created a GUI for creating that JRXML file? It can do all sorts of things. But I am not impressed with the way the demos are presented. You get a build.xml and you are told to run ant. But it errors and errors and errors. I am not impressed.

Look, demos need to run right out of the box. I should do no more than adding jars on my classpath.

This helpful page gets me started: http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html. I am able to generate a report out of Access!

No comments: