Skip to main content

SetText

Replaces the paragraph content with the specified text.

Syntax​

expression.SetText(text);

expression - A variable that represents an ApiParagraph class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
textRequiredstringThe text to set.

Returns​

ApiRun

Example​

Replace all text in a paragraph with a new string in a document.

// How do I overwrite the existing text of a paragraph in a document?

// Replace the original text with another text string.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is the original text.");
paragraph.SetText("This is the replacement text.");