DocumentBuilder nested altChunk

Jun 3, 2014 at 7:31 PM
I'm working on a project that had already been using OpenXml, and I'm trying to add a feature that uses PowerTools to merge static and generated DOCX files into a single DOCX. Everything works just fine if all the content is in static or Word-created files; the problem is when I try to merge the generated content.

The generated content consists of HTML pages (selected from a CMS), which are altChunks. When I call the DocumentBuilder.BuildDocument function -- which, essentially, adds the defined source files as altChunks to the output document -- is unable to run because of these altChunks. They basically become "nested" -- the generated content file can't be "altChunked" into the output document because it contains altChunks.

Except for this issue with the generated content, everything I've got works well and the DocumentBuilder is lightning fast; I'd really hate to start over or do too much rebuilding if I can avoid it. I'm wondering if anyone has discovered a way to use the DocumentBuilder with files that already contain altChunks. Or maybe there's a way to extract the altChunk content and use it as a source? (I'm not sure that would work, since a Source is a WmlDocument object.) Currently I have the client opening the generated content files in Word and resaving them, but this is obviously not a great solution.

Hopefully I'm not a pioneer in doing something like this, and someone has come up with a nifty solution to this sort of issue. I can try to post some code, but I'm not doing anything all that different from what you see in OpenXmlPowerToolsExamples\DocumentBuilder01. The only difference is that some of the content I'm trying to feed in has altChunks.

Thanks in advance for any helpful thoughts or suggestions.