Question

I have a project where I want to be able to format xhtml documents into both PDF format and Docx format.

I've been using flyingsaucer to format PDF documents for some time and always had to use an older version of iText for compatibility reasons. Now that I'm using docx4j I need to update iText to a more recent version or it won't work.

FlyingSaucer (xhtmlrenderer R8pre2) uses iText 2.0.8
docx4j 2.8.0 uses iText 2.1.7

I can only use one iText library but whichever one I use I end up with compatibility issues for either flying saucer or docx4j.

At the moment the problem seems to come down to one particular method (com.lowagie.text.pdf.BaseFont.getCharBBox) which in one version takes a char parameter and in the other it takes an int parameter.

I think I may have to download sources for either flyingsaucer or iText (I think they're both open source) and fix this myself (not something I've done before but I think I could manage) but I can imagine I'm not the 1st person to run into this problem and perhaps there's another way around it or someone else has already forked one of the projects to resolve this sort of issue.

Was it helpful?

Solution

Disclosure: I work on the docx4j project

docx4j 2.8.0 only uses iText, because it is required by our fork of Flying Saucer, which does the XHTML import.

In that fork, I added docx related stuff, and removed some stuff we didn't need. It's possible that in the future, we'll offer this back to Flying Saucer - it's a matter of having the time.

In the meantime I mention for completeness that you can have the real Flying Saucer and our fork on your class path at the same time, since our fork is re-packaged.

Back to your question, FlyingSaucer proper now has the same 2.1.7 dependency, so if you are able to use the current sources, that should address the issue you have raised.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top