Setting the dropdown font

The new aptos font is causing me all kinds of weird problems. Can you help me with this, I have the following that creates a dropdown list. However, it’s not defaulting to aptos size 12 font. How can i set the font and size of the created dropdown?

StructuredDocumentTag sdtListBox = new StructuredDocumentTag(target, SdtType.DropDownList, MarkupLevel.Inline);
foreach (var listitem in data_list.list_items)
{
    if (listitem.content.Trim().Length > 0)
    {
        sdtListBox.ListItems.Add(new SdtListItem(listitem.content.Trim()));
    }
}
sdt.AppendChild(sdtListBox);

@markchequer You can use StructuredDocumentTag.ContentsFont property to specify font of the SDT:

Document doc = new Document();

StructuredDocumentTag sdtListBox = new StructuredDocumentTag(doc, SdtType.DropDownList, MarkupLevel.Inline);
// Spacify font of the content control's content.
sdtListBox.ContentsFont.Name = "Aptos";
sdtListBox.ContentsFont.Size = 20;

string[] items = new string[] { "First", "Second", "Third" };
foreach (string listitem in items)
{
    sdtListBox.ListItems.Add(new SdtListItem(listitem));
}
doc.FirstSection.Body.FirstParagraph.AppendChild(sdtListBox);

doc.Save(@"C:\Temp\out.docx");

Perfect. Thank you!

1 Like