Skip to main content

GetStyle

Returns the paragraph style method.

Inherited from ApiParaPr.GetStyle.

Example

Retrieve the style applied to a paragraph and display its name in a document.

// How do I get the current style of a paragraph in a document?

// Confirm which named style is active on a paragraph by reading and printing the style name in a document.

let doc = Api.GetDocument();
let heading6Style = doc.GetStyle("Heading 6");
let paragraph = doc.GetElement(0);
let paraPr = paragraph.GetParaPr();
paraPr.SetJc("center");
paraPr.SetStyle(heading6Style);
paragraph.AddText("This is a text in a paragraph styled with the 'Heading 6' style.");
let style = paraPr.GetStyle();
paragraph.AddLineBreak();
paragraph.AddText("Style: " + style.GetName());