Get Started
Documentation

SetNumPr

SetNumPr(oNumPr, [nLvl])

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

Parameters:

Name Type Default Description
oNumPr ApiNumbering

Specifies a numbering definition.

nLvl number 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.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oParaPr, oNumbering;
var oMyStyle = oDocument.CreateStyle("My document style");
oParaPr = oMyStyle.GetParaPr();
oNumbering = oDocument.CreateNumbering("bullet");
oParaPr.SetNumPr(oNumbering);
var oNumLvl;
for (var nLvl = 0; nLvl < 8; ++nLvl) {
  oNumLvl = oNumbering.GetLevel(nLvl);
  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);
builder.SaveFile("docx", "SetNumPr.docx");
builder.CloseFile();

Resulting document