Page 1 of 1

Using docx4j with Word 2007 templates

PostPosted: Tue Jun 02, 2009 12:16 pm
by boz0413
Hi,

I am a new user of docx4j and am looking to use the library to manipulate Word 2007 templates (.dotx). I specifically want to edit placeholders in these templates and create complete Word documents (.docx) from them.

Has anyone attempted this before? A basic example to get me started would be much appreciated.

Thanks in advance.

Re: Using docx4j with Word 2007 templates

PostPosted: Wed Jun 03, 2009 11:47 am
by jason
In http://dev.plutext.org/trac/docx4j/brow ... Utils.java, we have:

Code: Select all
public static Object unmarshallFromTemplate(String wmlTemplateString, java.util.HashMap<String, String> mappings)


For an example of its use, see http://dev.plutext.org/trac/docx4j/brow ... plate.java

Here are some links to using bound content controls, which may be more what you want:


Let me know if you decide to use this latter approach; I'm interested in supporting that in docx4j, and can give you a hand, particularly if you contribute the basic code.

Re: Using docx4j with Word 2007 templates

PostPosted: Wed Jun 24, 2009 4:33 pm
by jason
With the code in svn, you can now do apply bindings specified in content controls to an xml document you've included in a custom xml part.

For an example, see http://dev.plutext.org/trac/docx4j/brow ... nding.java

This is a proof of concept, but its quite capable of substituting text from the custom xml into the document proper.

You'll probably want to use the content control toolkit (google for it) to set things up.

cheers

Jason