How can I keep each merged document content inside a content control ?

Feb 22, 2012 at 8:31 AM

Hi,

How can I keep each merged document content inside a content control ?

Regards

ce qui concerne
Coordinator
Feb 22, 2012 at 8:48 AM

Hi,

Take a look at this screen-cast.  It shows how to import a document to the contents of a content control.

http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2011/09/23/advanced-use-of-documentbuilder-2-0.aspx

-Eric

Feb 22, 2012 at 9:49 AM

Thanx Eric; this is helpful.

Feb 23, 2012 at 2:34 PM
Edited Feb 23, 2012 at 2:35 PM

This works fine for content controls inside document body but not for content controls in headers and footers, I am getting all content controls in this way :

 

List<XElement> contentControls = new List<XElement>();           
            foreach (var openXmlPart in wordprocessingDocument.GetAllParts())
            {
                contentControls .AddRange(openXmlPart.GetXDocument().Root.Descendants(W.sdt));
            }

First the content controls are duplicated, second the content controls in header footers are empty.

Regards

 

Coordinator
Feb 23, 2012 at 2:58 PM

DocumentBuilder does not support assembling content into headers and footers.  It is not a feature of the example.  It is a great idea, however, it was not something that we contemplated.  DocumentBuilder has very specific functionality around headers and footers, mainly associated with how sections are pulled into the assembled document from the source documents, but that is the extent to which DocumentBuilder deals with headers and footers.

-Eric