Hello! I've tackled with this problem few weeks ago. And my solution is in using AltChunk element of OOXML format. It's already works but there is one problem for which I have no simple solution. The problem is conflicts between styles of documents we try to merge.
Here is my topic about adding AltChunk throught the Apache POI library http://www.cyberforum.ru/java/thread1737393.html It's in russian but java code is quite comprehensive, i guess)) >Воскресенье, 7 августа 2016, 23:29 +03:00 от Cory Newey ><cory.ne...@gmail.com>: > >Hello All: > >I've tried to check the FAQ for this question and was unable to find >anything. I'm not sure if this should be a question for the developers' >list; I couldn't really tell from the brief description of the various >lists. Anyway, I figured I'd ask the question here and you guys could >bounce me over to the developers' list if that is the appropriate place for >this question. > >I have written a program that will merge changes (replace certain words >with other words/phrases) into a Word (docx) document using XWPFDocument. >But now I want to replace words/sections of one Word document with an >entire other Word document. I've tried to update my program so that it >iterates through the paragraphs/runs of the document to be merged in. It >merges the text just fine but it loses all formatting, tables, etc. I've >googled the question and found a few Stack-Overflow posts that talked about >it, but nothing was of any use to me. > >My question is: is it possible to merge one Word document into another Word >document, such that it copies all formatting, tables, etc from the >merged-in document (minus any headers/footers - that would be a little >impossible I think) into the merged-into document - using the XWPFDocument >object? > >Thanks in advance for any help. >~Cory