[jdom-interest] Generating PDF output using JDOM with iText

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu Feb 7 01:39:20 PST 2002


Hi,

Roland wrote:
> Hello,
> I'm new to JDOM and here is what I want to do:
> 
> I want to take the whole tree and make it output a PDF file using 
> iText(http://www.lowagie.com/iText/).
> To those who don't know what iText is: it is a library that enables you 
> to produce PDF documents from Java.
> I was thinking about adding a class to org.jdom.output to enable this.
> 
> My interest is to keep this as flexible as possible. So that I could 
> generate output to XSL:FO if I wanted, by just writing another output 
> class. I wonder why there wasn't defined a general output class from 
> which the existing ones inherit.
> 
> Does anyone have an idea of what would be the best way of implementing 
> my idea?

The best is to use the existing classes present in JDOM's core:

- To interface directly with iText, you can directly use SAXOutputter (There's 
an example in iText tutorial that shows how to interface iText to a SAX parser 
using SAXiTextHandler) but it seems iText only supports SAX1 while JDOM 
supports SAX2. Without SAX2 support in iText this won't work.

- To interface with an XSLT processor that will rely on a stylesheet to 
generate XSL-FO output, you can use the org.jdom.transform.JDOMSource which 
extends the javax.xml.transform.sax.SAXSource recognized by all the XSLT 
processors supporting the JAXP TrAX interface (Xalan, Saxon, jd-xslt...).

Hope this helps,

Laurent




More information about the jdom-interest mailing list