Note: I’ve removed the linked files. Email me if you’d like them.
Every once in a while, it comes up on the WebObjects list about how to generate a PDF. Lots of proprietary solutions are suggested, but there’s also a free one: Apache’s FOP, which can take an XML file + an XSL file and produce a PDF. If you use a checkout from the development tree, you can also generate RTF. Even if you don’t use FOP but use some other cool XSL-FO renderer, this will show you how to approach the problem.
This project also shows use of WOXMLCoder, which I know is way underdocumented.
As a warning, this isn’t intended to be production code, it’s just something I wrote in an evening to show how it all works together. I’ve used itext as well; it’s a lot more work.
You can get the project source (use however you like) and sample PDF by clicking on the appropriate links.
If you want to use this code, all you’ve really got to do is download Apache FOP and make sure all of its jars (from build and lib — there should be six in all) are copied to /Library/WebObjects/Extensions. Alternatively, you can wrap them in a framework if you’re on Xcode. For Eclipse users, just add the jars to your project.
p>I built this project on Xcode using WebObjects 5.2.3, fyi.