# Caret Annotation

## Content

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.
![Caret-Annotation.png](https://cdn.mescius.io/document-site-files/images/706ce9b9-7836-44f3-b62b-7d4408387ae3/Caret-Annotation-20260424.856ae5.png?width=720)
Use the [CaretAnnotation ](https://developer.mescius.com/document-solutions/javascript-pdf-api/api/classes/CaretAnnotation)class to add caret annotations to a PDF document.

>type=note
> **Note:** The examples on this page use helper functions from the [Snippet Helpers](https://developer.mescius.com/document-solutions/javascript-pdf-api/docs/snippet-helpers) module. These utilities are provided only to simplify the examples and are not part of the DsPdfJS API.

```javascript
// 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);
```