This project has moved. For the latest updates, please go here.

Replace content control with html

Nov 18, 2011 at 8: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.

Coordinator
May 28, 2012 at 9:55 AM
Edited May 28, 2012 at 11:57 AM

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++)
{
    body.Append(paragraphs[i]);
}