TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

RemoveElement

RemoveElement(nPos)

Removes an element using the position specified.

Parameters:

Name Type Description
nPos number

The element number (position) in the document or inside other element.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph0 = oDocument.GetElement(0);
oParagraph0.AddText("This is paragraph #1.");
for (let nParaIncrease = 0; nParaIncrease < 4; ++nParaIncrease) {
  var oParagraph = Api.CreateParagraph();
  oParagraph.AddText("This is paragraph #" + (nParaIncrease + 2) + ".");
  oDocument.Push(oParagraph);
}
oDocument.RemoveElement(2);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("We removed paragraph #3, check that out above.");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "RemoveElement.docx");
builder.CloseFile();

Resulting document