Get Started
Usage API
More information

ApiBlockLvlSdt

new ApiBlockLvlSdt()

Class representing a container for the document content.

Methods

Name Description
AddElement

Add a paragraph or a table or a blocklvl content control to the document.

AddText

Add a text to the current content control.

Delete

Remove content control and content. If keepContent is true, the content is not deleted.

GetAlias

Get the alias attribute for this container.

GetAllContentControls

Get the collection of content control objects in the content control.

GetAllDrawingObjects

Get the collection of drawing objects in the document.

GetAllParagraphs

Get a collection of paragraph objects in a content control.

GetAllTablesOnPage

Get a collection of tables on a given absolute page. This method can be a little bit slow, because it runs the document calculation process to arrange tables on the specified page.

GetClassType

Get the type of this class.

GetContent

Get the content of this container.

GetLabel

Get the label attribute for this container.

GetLock

Get the lock type of this container.

GetParentContentControl

Get the content control that contains the current content control.

GetParentTable

Get the table that contains the content control.

GetParentTableCell

Get the table cell that contains the content control.

GetRange

Return a Range object that represents the part of the document contained in the specified content control.

GetTag

Get the tag attribute for this container.

Push

Push a paragraph or a table or BlockLvl content control to actually add it to the document.

RemoveAllElements

Clear the contents from a content control.

Search

Search for the scope of a content control object. The search results are a collection of ApiRange objects.

Select

Select a content control.

SetAlias

Set the alias attribute for this container.

SetLabel

Set the label attribute for this container.

SetLock

Set the lock to the current inline text content control. "contentLocked" - content cannot be edited. "sdtContentLocked" - content cannot be edited and BlockLvlSdt cannot be deleted. "sdtLocked" - BlockLvlSdt cannot be deleted.

SetTag

Set the tag attribute for this container.

SetTextPr

Apply text settings to content of content control.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oBlockLvlSdt = Api.CreateBlockLvlSdt();
oBlockLvlSdt.GetContent().GetElement(0).AddText("This is the first paragraph of the content control.");
oContent = oBlockLvlSdt.GetContent();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is the second paragraph of the content control.");
oContent.AddElement(oParagraph);
oContent.Push(oParagraph);
oDocument.AddElement(0, oBlockLvlSdt);
aParagraphs = oBlockLvlSdt.GetAllParagraphs();
aParagraphs[0].SetBold(true);
oBlockLvlSdt.Search("paragraph")[1].SetItalic(true);
oBlockLvlSdt.SetLabel("2147483647");
oBlockLvlSdt.SetLock("sdtContentLocked");
oBlockLvlSdt.SetAlias("№1");
oBlockLvlSdt.SetTag("This is a tag.");
oLabel = oBlockLvlSdt.GetLabel();
oLock = oBlockLvlSdt.GetLock();
oAlias = oBlockLvlSdt.GetAlias();
oTag = oBlockLvlSdt.GetTag();
oClassType = oBlockLvlSdt.GetClassType();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class type: " + oClassType);
oParagraph.AddLineBreak();
oParagraph.AddText("Lock type: " + oLock);
oParagraph.AddLineBreak();
oParagraph.AddText("Label: " + oLabel);
oParagraph.AddLineBreak();
oParagraph.AddText("Alias: " + oAlias);
oParagraph.AddLineBreak();
oParagraph.AddText("Tag: " + oTag);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiBlockLvlSdt.docx");
builder.CloseFile();

Resulting document