We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert StructuredDocumentTag into document using DocumentBuilder in .NET

I am experimenting with the new capabilities of Aspose.Words 10.8 regarding structured document tags and I cannot figure out how I could generate the attached word document using the DocumentBuilder object. All I did so far is make the following code work:

var db = new Aspose.Words.DocumentBuilder();
db.StartTable();
db.InsertCell();
var sdt = new StructuredDocumentTag(db.Document, SdtType.PlainText, MarkupLevel.Inline);
db.InsertNode(sdt);
db.EndRow();
db.EndTable();
db.Document.Save("c:\\temp\\sdt.docx", Aspose.Words.SaveFormat.Docx);

But I cannot use different SdtTypes or MarkupLevels. Can you provide examples?

Hi Claude,

Thanks for your query. I have managed to reproduce the same problem at my end. I will discuss this issue with our development team and will update you further soon.

Hi Claude,


Thanks for your inquiry.

You are correct, there is currently some problems with creating new SDT. We will look into these as soon as possible.

In the mean time, just a few points:

  • Plain text content controls cannot be inserted at cell or row level which maybe one of the errors you first recieved. Instead you should use RichText content control instead.
  • There is currently no way to insert these tags into tables using DocumentBuilder but you can still do this manually i.e by creating a table from scratch using the Table, Row and Cell constructors and inserting SDT tags at the appropriate positions.
  • Currently there is a problem with creating row level Richtext SDT. We will fix this.

Thanks,