SdtType enumeration

Specifies the type of a structured document tag (SDT) node.

public enum SdtType


None0No type is assigned to the SDT.
Bibliography1The SDT represents a bibliography entry.
Citation2The SDT represents a citation.
Equation3The SDT represents an equation.
DropDownList4The SDT represents a drop down list when displayed in the document.
ComboBox5The SDT represents a combo box when displayed in the document.
Date6The SDT represents a date picker when displayed in the document.
BuildingBlockGallery7The SDT represents a building block gallery type.
DocPartObj8The SDT represents a document part type.
Group9The SDT represents a restricted grouping when displayed in the document.
Picture10The SDT represents a picture when displayed in the document.
RichText11The SDT represents a rich text box when displayed in the document.
PlainText12The SDT represents a plain text box when displayed in the document.
Checkbox13The SDT represents a checkbox when displayed in the document.
RepeatingSection14The SDT represents repeating section type when displayed in the document.
RepeatingSectionItem15The SDT represents repeating section item.
EntityPicker16The SDT represents an entity picker that allows the user to select an instance of an external content type.


Shows how to create a structured document tag of the Citation type.

Document doc = new Document();

StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.Citation, MarkupLevel.Inline);
Paragraph paragraph = doc.FirstSection.Body.FirstParagraph;

// Create a Citation field.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToParagraph(0, -1);
builder.InsertField(@"CITATION Ath22 \l 1033 ", "(John Lennon, 2022)");

// Move the field to the structured document tag.
while (sdt.NextSibling != null)

doc.Save(ArtifactsDir + "StructuredDocumentTag.Citation.docx");

Shows how to create group structured document tag at the Row level.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();

// Create a Group structured document tag at the Row level.
StructuredDocumentTag groupSdt = new StructuredDocumentTag(doc, SdtType.Group, MarkupLevel.Row);
groupSdt.IsShowingPlaceholderText = false;

// Create a child row of the structured document tag.
Row row = new Row(doc);

Cell cell = new Cell(doc);


// Insert cell contents.
builder.Write("Lorem ipsum dolor.");

// Insert text after the table.
builder.Write("Nulla blandit nisi.");

doc.Save(ArtifactsDir + "StructuredDocumentTag.SdtAtRowLevel.docx");

Shows how to work with styles for content control elements.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Below are two ways to apply a style from the document to a structured document tag.
// 1 -  Apply a style object from the document's style collection:
Style quoteStyle = doc.Styles[StyleIdentifier.Quote];
StructuredDocumentTag sdtPlainText =
    new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline) { Style = quoteStyle };

// 2 -  Reference a style in the document by name:
StructuredDocumentTag sdtRichText =
    new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline) { StyleName = "Quote" };


Assert.AreEqual(NodeType.StructuredDocumentTag, sdtPlainText.NodeType);

NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

foreach (Node node in tags)
    StructuredDocumentTag sdt = (StructuredDocumentTag)node;


    Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier);
    Assert.AreEqual("Quote", sdt.StyleName);

Shows how to fill a table with data from in an XML part.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

CustomXmlPart xmlPart = doc.CustomXmlParts.Add("Books",
    "<books>" +
        "<book>" +
            "<title>Everyday Italian</title>" +
            "<author>Giada De Laurentiis</author>" +
        "</book>" +
        "<book>" +
            "<title>The C Programming Language</title>" +
            "<author>Brian W. Kernighan, Dennis M. Ritchie</author>" +
        "</book>" +
        "<book>" +
            "<title>Learning XML</title>" +
            "<author>Erik T. Ray</author>" +
        "</book>" +

// Create headers for data from the XML content.
Table table = builder.StartTable();

// Create a table with a repeating section inside.
StructuredDocumentTag repeatingSectionSdt =
    new StructuredDocumentTag(doc, SdtType.RepeatingSection, MarkupLevel.Row);
repeatingSectionSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book", string.Empty);

// Add repeating section item inside the repeating section and mark it as a row.
// This table will have a row for each element that we can find in the XML document
// using the "/books[1]/book" XPath, of which there are three.
StructuredDocumentTag repeatingSectionItemSdt =
    new StructuredDocumentTag(doc, SdtType.RepeatingSectionItem, MarkupLevel.Row);

Row row = new Row(doc);

// Map XML data with created table cells for the title and author of each book.
StructuredDocumentTag titleSdt =
    new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Cell);
titleSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book[1]/title[1]", string.Empty);

StructuredDocumentTag authorSdt =
    new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Cell);
authorSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book[1]/author[1]", string.Empty);

doc.Save(ArtifactsDir + "StructuredDocumentTag.RepeatingSectionItem.docx");

See Also