This project has moved and is read-only. For the latest updates, please go here.

Replace content control with html

Nov 18, 2011 at 9:18 PM

I used alt chunk to replace content control with html text. I find this real cool api. Is there a way i can append paragraphs to content controls directly instead of body.

May 28, 2012 at 10:55 AM
Edited May 28, 2012 at 12:57 PM

Sorry I know this is far too late but for any other readers may be happy to read a solution :)

I really need a reference to the MainDocumentPart because I need to handle the Styles (read them and push new ones), insert Images, add foot notes, hyperlinks, ...

But you insert the paragraphs where you want. This is my example using body but it's just OpenXml and you decide the most appropriate location.


HtmlConverter converter = new HtmlConverter(mainPart);
var paragraphs = converter.Parse(html);
for (int i = 0; i < paragraphs.Count; i++)