# TextMarkup

**Text Markup annotations** appear as highlights, underlines, strikeouts, or jagged ("squiggly") underlines in the text of a document. When opened, they display a pop-up window containing the text of the associated note.

![Text Markup Annotation](https://www.telerik.com/document-processing-libraries/documentation/assets/ceaa3cebf50939cb252b6dae7d9fd244/pdf-processing-create-text-markup-annotation.png)

The `TextMarkupAnnotation` class is a derivative of `MarkupAnnotation` (descendent of `ContentAnnotation`) and it exposes the following properties:

| Property         | Description                                                                                                                                                                                                                                                |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `TextMarkupType` | Gets the type of the annotation. The `TextMarkupAnnotationType` enum offers `Highlight`, `StrikeOut`, `Underline`, and `Squiggly` options.                                                                                                                 |
| `Opacity`        | Gets or sets the opacity of the annotation.                                                                                                                                                                                                                |
| `Contents`       | Gets or sets the text displayed for the annotation.                                                                                                                                                                                                        |
| `Color`          | Gets or sets the color of the annotation.                                                                                                                                                                                                                  |
| `Content`        | Gets the source defining the visual content of the annotation. This content has higher priority compared to the annotation appearance characteristics and text properties and is visualized by default when opening the exported document in a PDF viewer. |

Depending on the `TextMarkupAnnotationType`, you can add the respective type of TextMarkup annotation to the PDF document using the following examples.

## Highlight

### Creating a Highlight Annotation

```C#
string sampleText = File.ReadAllText("dummyText.txt");

RadFixedDocument fixedDocument = new RadFixedDocument();
using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument))
{
    documentEditor.InsertRun(sampleText);
}

TextSearch search = new TextSearch(fixedDocument);
IEnumerable<SearchResult> result = search.FindAll("amet", TextSearchOptions.Default);
foreach (SearchResult r in result)
{
    Rect highlightRectangle = r.GetWordBoundingRect();
    TextMarkupAnnotation annotation = r.GetResultPage().Annotations.AddHighlight(highlightRectangle);
    annotation.Color = new RgbColor(125, 255, 0, 0);

    annotation.RecalculateContent();
}
```

![Create Highlight Annotation](https://www.telerik.com/document-processing-libraries/documentation/assets/cf069bc225bbb8db023e277ecce6197e/pdf-processing-create-highlight-annotation.png)

### Creating a Highlight Annotation with Appearance

```C#
private RadFixedDocument CreateTextMarkupAnnotation()
{
    string sampleText = File.ReadAllText("dummyText.txt");
    RadFixedDocument fixedDocument = new RadFixedDocument();
    using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument))
    {
        documentEditor.InsertRun(sampleText);
    }
    TextMarkupAnnotation annotation = fixedDocument.Pages[0].Annotations.AddHighlight(new Rect(150, 150, 100, 40));

    FormSource simpleForm = new FormSource();
    CreateContentFormWithText(simpleForm, "Hover me!");
    annotation.Content.NormalContentSource = simpleForm;

    FormSource secondForm = new FormSource();
    CreateContentFormWithText(secondForm, "Hovered!");
    annotation.Content.MouseOverContentSource = secondForm;
    return fixedDocument;
}

private static void CreateContentFormWithText(FormSource normalForm, string text)
{
    Size s = new Size(100, 40);
    normalForm.Size = s;

    FixedContentEditor formEditor = new FixedContentEditor(normalForm);

    using (formEditor.SaveProperties())
    {
        formEditor.GraphicProperties.IsFilled = true;
        formEditor.GraphicProperties.IsStroked = true;
        formEditor.GraphicProperties.StrokeThickness = 1;
        formEditor.GraphicProperties.StrokeColor = new RgbColor(255, 0, 0);
        formEditor.GraphicProperties.FillColor = new RgbColor(175, 255, 255, 0);
        formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 };
        formEditor.DrawRectangle(new Rect(0, 0, s.Width, s.Height));
    }

    formEditor.TextProperties.FontSize = 16;
    formEditor.TextProperties.Font = FontsRepository.Courier;
    formEditor.Position.Translate(10, 10);
    formEditor.DrawText(text);
}
```

![Create Highlight Annotation with Appearance](https://www.telerik.com/document-processing-libraries/documentation/assets/d2c5424085cf3321873bb9fe79f864e5/pdf-processing-create-highlight-annotation-with-appearance.gif)

> important In **.NET Standard/.NET (Target OS: None)** environments, fonts beyond the [14 standard ones](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/fonts#standard-fonts) require a [FontsProvider implementation](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdfprocessing-implement-fontsprovider) to be resolved correctly.

## Underline

```C#
RadFixedDocument fixedDocument = new RadFixedDocument();
RadFixedPage page = fixedDocument.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(100, 100);
editor.DrawText("This is an underline.");

TextSearch search = new TextSearch(fixedDocument);
IEnumerable<SearchResult> underlineSearch = search.FindAll("underline", TextSearchOptions.Default);
Rect underlineRectangle = underlineSearch.First().GetWordBoundingRect();
TextMarkupAnnotation underlineAnnotation = page.Annotations.AddUnderline(underlineRectangle);
underlineAnnotation.Color = new RgbColor(255, 0, 255);
underlineAnnotation.Opacity = 0.90;
underlineAnnotation.RecalculateContent();
```

![Create Underline Annotation](https://www.telerik.com/document-processing-libraries/documentation/assets/1b10fbe128a7b82d4fb8554943769729/pdf-processing-create-underline-annotation.png)

## Squiggly

```C#
RadFixedDocument fixedDocument = new RadFixedDocument();
RadFixedPage page = fixedDocument.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(100, 100);
editor.DrawText("This is a squiggly line.");

TextSearch search = new TextSearch(fixedDocument);
IEnumerable<SearchResult> squigglySearch = search.FindAll("squiggly", TextSearchOptions.Default);
Rect squigglyRectangle = squigglySearch.First().GetWordBoundingRect();
TextMarkupAnnotation squigglyAnnotation = page.Annotations.AddSquiggly(squigglyRectangle);
squigglyAnnotation.Color = new RgbColor(255, 0, 0);
squigglyAnnotation.Opacity = 0.70;
squigglyAnnotation.RecalculateContent();
```

![Create Squiggly Annotation](https://www.telerik.com/document-processing-libraries/documentation/assets/18e9fa89ae681ca5276d1c78bf56f7a2/pdf-processing-create-squiggly-annotation.png)

## StrikeOut

```C#
RadFixedDocument fixedDocument = new RadFixedDocument();
RadFixedPage page = fixedDocument.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(100, 100);
editor.DrawText("This is a strikeout.");

TextSearch search = new TextSearch(fixedDocument);
IEnumerable<SearchResult> strikeoutSearch = search.FindAll("strikeout", TextSearchOptions.Default);
Rect strikeoutRectangle = strikeoutSearch.First().GetWordBoundingRect();
TextMarkupAnnotation strikeoutAnnotation = page.Annotations.AddStrikeout(strikeoutRectangle);
strikeoutAnnotation.Color = new RgbColor(0, 0, 255);
strikeoutAnnotation.Opacity = 0.90;
strikeoutAnnotation.RecalculateContent();
```

![Create StrikeOut Annotation](https://www.telerik.com/document-processing-libraries/documentation/assets/d1538d5443e9769e2aaa8824c18229da/pdf-processing-create-strikeout-annotation.png)

## See Also

* [AcroForm](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/acroform)
* [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields)
* [Annotations Overview](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/annotations/overview)
* [FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/overview)
