SetNumPr

function SetNumPr(oNumPr: ApiNumbering = null, nLvl: number = 0): void

Description

Specifies that the current paragraph references a numbering definition instance in the current document.

Parameters

oNumPrApiNumberingdefault: null

Specifies a numbering definition.

nLvlnumberdefault: 0

Specifies a numbering level reference. If the current instance of the ApiParaPr class is direct formatting of a paragraph, then this parameter MUST BE specified. Otherwise, if the current instance of the ApiParaPr class is the part of ApiStyle properties, this parameter will be ignored.

Returns

void

Try It

var oDocument = Api.GetDocument();
var oMyStyle = oDocument.CreateStyle("My document style");
var oParaPr = oMyStyle.GetParaPr();
var oNumbering = oDocument.CreateNumbering("bullet");
oParaPr.SetNumPr(oNumbering);
for (let nLvl = 0; nLvl < 8; ++nLvl) {
   var oNumLvl = oNumbering.GetLevel(nLvl);
   var oParagraph = Api.CreateParagraph();
   oParagraph.AddText("Default bullet lvl " + (nLvl + 1));
   oParagraph.SetNumbering(oNumLvl);
   oParagraph.SetContextualSpacing(true);
   oDocument.Push(oParagraph);
}
oParagraph = Api.CreateParagraph();
oParagraph.SetStyle(oMyStyle);
oParagraph.AddText("This is a paragraph styled as a bulleted list.");
oDocument.Push(oParagraph);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).