Page 1 of 1

Inserting another docx into docx

PostPosted: Fri Apr 04, 2014 2:47 pm
by hillmanytli
Hello Jason, I am now researching the feasibility of using docx4j to revamp our document generation system. There is a master document and a number of component documents. Depending on user inputs, the component documents may or may not be present in the master. The od:component tag seems to be a solution, but I cannot find an example of using it. Could you give some hints here? Do I need the paid extensions in order to do this task?

Re: Inserting another docx into docx

PostPosted: Sat Apr 05, 2014 7:38 am
by jason
Hi there, the underlying approach of interest here is "altChunk" of type docx.

If you include your docx as an altChunk, then the first time it is opened in Word, Word will incorporate its contents.

If you need that to happen earlier (eg to create HTML or PDF output using docx4j, or for greater control/certainty, or because your users might open the docx in something other than Word), then Plutext's Docx4j Enterprise Edition's MergeDocx component can do this.

By the way, docx4j's OpenDoPE implementation now also supports binding an XML element which contains base64 encoded docx content. It'll convert that to an altChunk, and if you have the MergeDocx component, that'll in turn convert it to "real" docx content.

You can download a trial of the Enterprise Edition, from http://www.plutext.com/m/index.php/products

Re: Inserting another docx into docx

PostPosted: Tue Apr 08, 2014 5:34 pm
by hillmanytli
Thank you Jason. I look at the sample AltChunkAddOfTypeDocx. It is awesome. It should solve most of the problems. The example inserts the chunk at the end of the document. I find that the method addAltChunk allows me to specify the insertion point which is a content accessor. I think I will use a P element as the insertion for this case.