[]
A caret annotation is a visual symbol used to indicate where text should be inserted or modified. It is commonly used during document review to mark missing text or suggested changes.

Use the CaretAnnotation class to add caret annotations to a PDF document.
// load PDF.
const inputDocData = await Util.loadFile("Wetlands.pdf");
const doc = PdfDocument.load(inputDocData);
// Insert the CaretAnnotation after "The Importance" text.
const positions = doc.findText({ text: "The Importance", matchCase: false, wholeWord: false }, { pageNumbers: [1] });
for (const pos of positions) {
// r is bounds of the found text.
var r = Util.quadrilateralToRect(pos.bounds[0]);
// Create the CaretAnnotation and add it to the page.
const ca = new CaretAnnotation();
ca.page = doc.pages.getAt(pos.pageIndex);
// in this code annotation size is hardcoded, you can make a code
// which will adjust size of the annotation depending on height of the found text fragment
ca.rect = { x: r.x + r.width - 4, y: r.y + r.height - 8, width: 8, height: 8 };
ca.opacity = 1;
ca.color = "Red";
ca.contents = "This is Caret annotation.";
}
const docData = doc.savePdf();
Util.saveFile("CaretAnnotation.pdf", docData);