When we try to insert html to a Paragraph inside a StructuredDocumentTag we get a NullReferenceException.
We want to insert html inside a StructuredDocumentTag.
Here is our code:
var doc = new Aspose.Words.Document();
var builder = new Aspose.Words.DocumentBuilder(doc);
var structuredDocumentTag = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);
var paragraphContainer = new Paragraph(doc);
structuredDocumentTag.AppendChild(paragraphContainer);
builder.MoveTo(paragraphContainer);
builder.InsertHtml(@"<div> </div>");
Can you please help us with it? (are we doing something wrong? there is a workaround?)
Thanks for your inquiry. Please use following highlighted line of code to get the required output. Hope this helps you.
var doc = new Aspose.Words.Document();
var builder = new Aspose.Words.DocumentBuilder(doc);
var structuredDocumentTag = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);
var paragraphContainer = new Paragraph(doc);
structuredDocumentTag.AppendChild(paragraphContainer);
doc.FirstSection.Body.AppendChild(structuredDocumentTag);
builder.MoveTo(paragraphContainer);
builder.InsertHtml(@"<div>Test </div>");