views:

251

answers:

4

I am trying to covert a word document to pdf using java. 'word to XSL-FO to pdf' is the approach i am looking at.

In this approach to do 'word to XSL-FO', is there any open source api available? or can you please guide me with steps for implementing it?

+1  A: 

What version of Word document are you converting?

RenderX has WordML2FO stylesheets publicly available that can convert Microsoft's WordprocessingML documents to XSL FO (XSLFO).

These stylesheets were prepared by RenderX's development team and Microsoft for general use. They are used to convert documents in Microsoft's WordprocessingML XML vocabulary into documents in the W3C's XSL FO (XSLFO) vocabulary.

Mads Hansen
A: 

I totally think that using just a stylesheet is not the way to go because there are too many things you will miss (like resolving styles, drawingml/vml used for the graphics inside a docx/word2003 document, etc). Try this code sample and move from there. Also to note is that if you generate your Word 2003/2007 using Microsoft's API, the structure of it may not be correct all the time unless you make all the required function calls.

XMLDUDE
A: 

docx4j (open source, Apache license) can do this for you.

See the docx4j Getting Started guide for further details.

plutext
A: 

You could also try Docmosis or JODConverter to do the conversion as long as you can install OpenOffice somewhere. They work on many platforms and can be Java controlled.

jowierun