Skip to main content

RemoveElement

Removes an element using the position specified.

Syntax​

expression.RemoveElement(pos);

expression - A variable that represents an ApiRichContent class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
posRequirednumberThe element number (position) in the rich content.

Returns​

boolean

Example​

Delete an element from rich content in a PDF.

// How can I remove elements from rich content in a PDF?

// Take out a specific item from the content area in a PDF.

let doc = Api.GetDocument();
let freeTextAnnot = Api.CreateFreeTextAnnot([160, 50, 360, 135]);
let page = doc.GetPage(0);
page.AddObject(freeTextAnnot);
freeTextAnnot.SetIntent("freeTextCallout");
freeTextAnnot.SetCallout([{x: 161, y: 51}, {x: 249, y: 125}, {x: 261, y: 125}]);
freeTextAnnot.SetRectDiff([100, 64, 0.5, 0.5]);

let richContent = freeTextAnnot.GetContent();
let para = Api.CreateRichParagraph();
para.AddText("Example text");
richContent.Push(para);
richContent.RemoveElement(0);

console.log(`We removed first paragraph from content`);