# Caret Annotation

DsPdf is a Document Solutions product that offers a rich library to read, create, modify, and save PDF files without using any external tool.

## Content

Caret annotation is a visual symbol typically used to mark text for some changes or to indicate some missing text. DsPdf provides [CaretAnnotation](/document-solutions/dot-net-pdf-api/api/online/DS.Documents.Pdf/GrapeCity.Documents.Pdf.Annotations.CaretAnnotation.html) class that allows a user to add Caret annotations to the PDF file.
![](https://cdn.mescius.io/document-site-files/images/884d2bfb-301b-49bc-8d90-656c5b910507/images/caret-annotation.png)
CaretAnnotation class provides the following properties to set various options for the caret annotation:

| **Property** | **Description** |
| -------- | ----------- |
| UserName | Adds the user name to the text label in the title bar of the annotation’s pop-up window when the annotation is open and active. |
| Subject | Adds the text representing the subject of the annotation. |
| Contents | Adds the text to the annotation for display. |
| RichText | Adds the text to the annotation for display in the pop-up window when opened. You can format this text using HTML tags. |
| Opacity | Sets the opacity of the annotation. |
| Color | Sets the annotation color, popup window color, line color, etc. |
| Rect | Adds the rectangle that defines the location and size of the annotation on a page. The coordinates of the rectangle are relative to the upper left corner of the page's media box, with the Y (vertical) coordinates increasing from top to bottom. |

Refer to the following example code to add a caret annotation to a PDF document:

```csharp
// Initialize GcPdfDocument.
GcPdfDocument doc = new GcPdfDocument();

// Create a file stream.
FileStream fs = new FileStream("Wetlands.pdf", FileMode.Open, FileAccess.Read);

// Load the file stream.
doc.Load(fs);

// Get the first page.
var page = doc.Pages[0];
            
// Get the text map.
var tm = page.GetTextMap();

// Insert the CaretAnnotation after "The Importance" text.
tm.FindText(new FindTextParams("The Importance", false, true), (fp_) =>
{
    // r is bounds of the found text.
    var r = fp_.Bounds[0].ToRect();
    // Create the CaretAnnotation and add it to the page.
    CaretAnnotation ca = new CaretAnnotation();
    ca.Page = page;
    // 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 = new System.Drawing.RectangleF(r.Right - 4, r.Bottom - 8, 8, 8);
    ca.Opacity = 1f;
    ca.Color = Color.Red;
    ca.Contents = "This is Caret annotation.";
});

doc.Save("CaretAnnotation.pdf");
```