跳到主要内容

Reset text properties

Resets the text properties of all the paragraphs in a document to the default settings.

(function () {
let doc = Api.GetDocument();

// Create a new text properties object with default settings
let defaultTextPr = Api.CreateTextPr();
defaultTextPr.SetFontSize(24);
defaultTextPr.SetFontFamily("Arial");
defaultTextPr.SetBold(false);
defaultTextPr.SetItalic(false);
defaultTextPr.SetHighlight("white");
defaultTextPr.SetColor("black");
defaultTextPr.SetUnderline(false);

let paragraphs = doc.GetAllParagraphs();

for (let i = 0; i < paragraphs.length; i++) {
// Apply text properties
paragraphs[i].SetTextPr(defaultTextPr);
}
})();

Methods used: GetDocument, CreateTextPr, SetFontSize, SetFontFamily, SetBold, SetItalic, SetHighlight, SetColor, SetUnderline, GetAllParagraphs, SetTextPr

Result

ResetTextProperties ResetTextProperties