Get Started
Usage API
More information

ApiBlockLvlSdt

new ApiBlockLvlSdt()

Class representing a container for the document content.

Methods

Name Description
AddComment

Adds a comment to the content control. Note: must be in the document.

AddElement

Adds a paragraph or a table or a block content control to the current container.

AddText

Adds a text to the current content control.

Delete

Removes a content control and its content. If keepContent is true, the content is not deleted.

GetAlias

Returns the alias attribute for the current container.

GetAllContentControls

Returns a collection of content control objects in the current content control.

GetAllDrawingObjects

Returns a collection of drawing objects in the current content control.

GetAllParagraphs

Returns a collection of paragraph objects in the current content control.

GetAllTablesOnPage

Returns 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

Returns a type of the ApiBlockLvlSdt class.

GetContent

Returns the content of the current container.

GetLabel

Returns the label attribute for the current container.

GetLock

Returns the lock type of the current container.

GetParentContentControl

Returns a content control that contains the current content control.

GetParentTable

Returns a table that contains the current content control.

GetParentTableCell

Returns a table cell that contains the current content control.

GetPlaceholderText

Returns the placeholder text from the current content control.

GetPosInParent

Returns the content control position within its parent element.

GetRange

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

GetTag

Returns the tag attribute for the current container.

Push

Pushes a paragraph or a table or a block content control to actually add it to the current container.

RemoveAllElements

Clears the contents from the current content control.

ReplaceByElement

Replaces the current content control with a new element.

Search

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

Select

Selects the current content control.

SetAlias

Sets the alias attribute to the current container.

SetBackgroundColor

Sets the background color to the current sdt.

SetLabel

Sets the label attribute to the current container.

SetLock

Sets the lock to the current block text content control: "contentLocked" - content cannot be edited. "sdtContentLocked" - content cannot be edited and the container cannot be deleted. "sdtLocked" - the container cannot be deleted.

SetPlaceholderText

Sets the placeholder text to the current content control.

SetTag

Sets the tag attribute to the current container.

SetTextPr

Applies text settings to the content of the content control.

ToJSON

Converts the ApiBlockLvlSdt object into the JSON object.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oBlockLvlSdt = Api.CreateBlockLvlSdt();
oBlockLvlSdt.GetContent().GetElement(0).AddText("This is the first paragraph of the content control.");
var oContent = oBlockLvlSdt.GetContent();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is the second paragraph of the content control.");
oContent.AddElement(oParagraph);
oContent.Push(oParagraph);
oDocument.AddElement(0, oBlockLvlSdt);
var 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.");
var oLabel = oBlockLvlSdt.GetLabel();
var oLock = oBlockLvlSdt.GetLock();
var oAlias = oBlockLvlSdt.GetAlias();
var oTag = oBlockLvlSdt.GetTag();
var sClassType = oBlockLvlSdt.GetClassType();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class type: " + sClassType);
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