I have a requirement to present a PDF on demand in a web application injecting user specific data. I'm looking at both Apache FOP and iText for the solution.
It seems to me that iText is a better fit for what we're doing. However, it would be ideal if we could separate the styling of the PDF from the code that generates the document. I don't see evidence of being able to separate the style from the document generation code in the simple iText examples that I've seen. Although I gather that this is the way it's done in Apache FOP.
Should I be considering using both rather than one or the other? From the iText mailing lists it does seem to me that people use both libraries together. Can I generate a document with all the data in iText and then apply the styles using FOP? It seems like FOP wants an XML document to work on.
How have people solved this problem? Both libraries have been around for a while so I assume people have, but I don't see much comment on this fact online.
Your perception is correct that using iText your style information would be part of the Java code (obviously, you could factor style info out into properties that get consulted when the PDF is created, but basically the Java code is where that information is specified).
FOP and iText are often mentioned together because FOP uses iText underneath; but that's completely transparent to FOP users.
FOP makes sense if your data is highly regular (lots of tables), or if you have XML data to begin with. Plus, maintaining XSL-FO stylesheets is a skill one needs to acquire, while iText's API approach should be familiar to every Java developer.