tags:

views:

229

answers:

2

I want to convert XPS to Word documents in Java. Can you help with the site or code to do this?

A: 

Have you had a look at http://code.google.com/p/java-axp/ ?

That allows you to read the XPS.

The easiest file format to generate to create Word documents is RTF. You can use iText for that.

Thorbjørn Ravn Andersen
I have downloaded the file but which file should i use for windows xp
jacinta
Do you want it as a standalone program, or as a Java framework?
Karel Bílek
A: 

Another way to produce word files is through POI HWPF. Or if you can afford it, you might want to use Aspose.

Another option is to produce word files directly. If you can use Word 2007, or Word 2003 with the plugin, then I'd recommend the .docx format. It's basically XML, although you'll have to invest at least a day or two to understand the format.

Here's how I would recommend learning about word .docx format.

  1. Write a very small document (a couple of lines) in Word, and save it as test.docx
  2. Rename test.docx to test.zip
  3. Unzip test.zip and look at the files that are inside.
  4. Be amazed at the complexity, depth, and unfriendly names of the XML elements.
  5. Perservere to try to understand the relationships between paragraphs (P), paragraph properties (PPr), Text, Runs, etc.
  6. Refer to the documentation (33MB zipped) to understand the finer details.
  7. Start writing code to create files in this format. Look at openxml4j as a tool for doing the 'packaging' -- putting together all those files with the .rels etc. You can also look at the source for some of the examples.
  8. If you download all the xsd schemas, you could use tools like Sun's jaxb or Apache's Xmlbeans to make nice java classes for P, PPr, R, RPr, etc.
John