Check out these two open source tools: JasperReports: Free Java report-generating library. XML report templates are used to generate ready to print documents using data from customizable data sources, including JDBC. The output can be delivered to the screen, printer, or stored in PDF, HTML or XML format. iText, a JAVA-PDF library: This library contains classes that generate documents in the Portable Document Format (PDF) and/or HTML.
First of all, which PDF library are you using? - iText - BigFaceless - PDFlib - GNUjpdf - Some other? There are also some commercial products specialized in generating PDF reports based on database tables, XML documents, etc.
Originally posted by Gregg Bolinger: Have you used iText? If so, how does it compare with FOP? Or is it similar enough that there is a comparison. I find iText pretty easy. Do just looking for opinions.
I haven't used iText so I really can't offer a comparison. I will point out that FOP is just an xsl-fo processor programmed in Java, which can be used stand-alone but also has an API which you can use to call it from within your code. It takes an xsl-fo document and can ouput pdf or a few other outputs. Is an fo based solution for you? If you want a non-proprietary solution, yes. Since xsl-fo is a w3c standard, any FO processor would be able to render an fo document, not just FOP. If you have a particular reason that using XML technologies would make sense for your project, then using something like FOP would be a good direction to head in. Our requirements were to make a complex multi-page printer-friendly version requiring precise layout of some web-based material. The basic flow we used was to produce a DOM (using JDOM) of a heirarchy of Java objects. Once we had our DOM, we transformed it using an xsl stylesheet to provide the proper xsl-fo markup, as well as a sprinkling of svg. We took the transformed DOM, and fed it to a servlet (in this case acting as a view for a Struts application) which rendered the pdf using FOP and produced an output stream of type application/pdf. The upside for us was that we will be able to re-use portions of that, particularly marshalling the objects to xml, for other requirements we have coming down the road. Additionally it is a relatively simple thing to do to change the xsl stylesheet if we have any tweaks we need to make, and we have maintained separation of our data and presentation.
Just as a side note, I was wondering whether any of these mentioned libraries (especially iText) are capable of streaming PDF files? I mean, pushing out blocks instead of creating the whole document in-memory and then flushing that out. I had to come up with an export feature for XLS and none of the available libraries supported true streaming so I had to write a simple report generator, which wrote the BIFF8 blocks one by one (they had to be written in a certain order required by the spec, which kind of made the code unreusable but...)
Originally posted by Jason Menard: I have done this using xsl-fo and FOP. I've been quite pleased with the results.
I'll second that. FOP was easy to use and learn. But watch out for memory consumption. I've heard this is a problem with a lot of these tools. FO has some techniques for reducing the memory footprint that should be followed. Cheers, Ron
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop