Rectangle 27 0

What's a good Java API for creating Word documents?


It was mentioned only briefly once, so I'd like to call out the docx4j library, as I've had more success with docx4j than anything else. Apache POI's support for Word documents isn't very good. Also, unlike Aspose.Words, docx4j is an open source library.

The only drawback is with docx4j you have to create Office Open XML (docx) format documents rather than OLE2-based (doc) format documents. This is the default format for Word 2007, but Word 2003 and earlier users will need to install a compatibility pack.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Note
Rectangle 27 0

What's a good Java API for creating Word documents?


It was mentioned only briefly once, so I'd like to call out the docx4j library, as I've had more success with docx4j than anything else. Apache POI's support for Word documents isn't very good. Also, unlike Aspose.Words, docx4j is an open source library.

The only drawback is with docx4j you have to create Office Open XML (docx) format documents rather than OLE2-based (doc) format documents. This is the default format for Word 2007, but Word 2003 and earlier users will need to install a compatibility pack.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Any knowledge of graph and table possibilities? How about tables of contents? Anyone have real experience doing those things in POI?

HWPF is the set of APIs for reading and writing Microsoft Word 97(-XP) documents using (only) Java.

I think Apache POI can do the job. A possible problem depending on the usage your aiming to may be caused by the fact that HWPF is still in early development.

I think you'd be better off using docx4j, but I would, since I work on that project. docx4j is focused on docx documents, and uses JAXB, not XML Beans.

Looking at the documentation for POI, it seems this HWPF is very early in development, mainly allowing for reading text out of a .doc, not really for dynamic creation of "complex" documents.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


best bet may be to convince the powers that be that PDF is the best technology for the job

After a little more research, I came across iText, a PDF and RTF-file creation API. I think I can use the RTF generation to create a Doc-readable file that can then be edited using Doc and re-saved.

Anyone have any experience with iText, used in this fashion?

Bill, the POI and iText API are very similar from a programming perspective. I've worked with both in the past and found them both easy to use and well documented.

However I believe the formatting in RTF is limited compared to DOC. I don't know if you'll be able to implement the advanced features you are looking for (tables, inline images) without a decent amount of hassle, if at all.

With iText you gain the advantage of being able to switch between formats (RTF and PDF) with minor change to the code. If I remember correctly the content is laid out using the same calls and then set as PDF or RTF using a few lines of code.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Thanks, but it looks like this would require running on a windows machine, no? I clarified the host machine OS after reading this, but thanks for the info.

Using JACOB on the web-server machine would require Microsoft Word itself to be installed on it, because creating and manipulating Word documents through COM interface requires bringing up actual instances of Word application. In general, such use of Word+COM on a multi-user server is quite problematic because Word is not designed for such use - for instance duplicating parts of the document is traditionally done using Selection object and Windows clipboard, which is unthinkable in web-server machine setting. i have been quite burned by this (although having found some tweaks)

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Aspose.Words for Java is an advanced (commercial) class library for Java that enables you to perform a great range of document processing tasks directly within your Java applications.

Aspose.Words for Java supports DOC, OOXML, RTF, HTML and OpenDocument formats. With Aspose.Words you can generate, modify, and convert documents without using Microsoft Word.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


IDocument myDoc = new Document2004();
myDoc.getBody().addEle(new Heading1("Heading01"));
myDoc.getBody().addEle(new Paragraph("This is a paragraph...")

*I wrote this because we had one real necessity in a project. More in my blog:

Does it support for creation of .docx files ? @Leonardo

Have you tested it using actual MS Word? I've managed to create files that OpenOffice and LibreOffice can read but not MSWord on windows. (I've reported this issue at code.google.com/p/java2word/issues/detail?id=16 )

I cannot open java2word generated files using OpenOffice ? Works fine with Office 2010

I implemented this API called Java2Word. with a few lines of code, you can generate one Microsoft Word Document.

Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Note
Rectangle 27 0

What's a good Java API for creating Word documents?


Note