Skip to main content

GetTextPr

Returns the text properties of the current run.

Syntax

expression.GetTextPr();

expression - A variable that represents a ApiRun class.

Parameters

This method doesn't have any parameters.

Returns

ApiTextPr

Example

Read the text formatting settings applied to a run in a document.

// How do I retrieve the current text formatting of a run in a document?

// Inspect and reuse the styling options already set on a piece of text in a document.

let doc = Api.GetDocument();
let myNewRunStyle = doc.CreateStyle("My New Run Style", "run");
let textPr = myNewRunStyle.GetTextPr();
textPr.SetCaps(true);
textPr.SetFontFamily("Calibri Light");
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
run.AddText("The text properties are changed and the style is added to the paragraph. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetStyle(myNewRunStyle);
run.AddText("This is a text run with its own style.");
paragraph.AddElement(run);