---
title: "Adding text markup annotations to a PDF document | Nutrient Java SDK"
canonical_url: "https://www.nutrient.io/guides/java/editor/add-text-markup-annotations-to-pdf/"
md_url: "https://www.nutrient.io/guides/java/editor/add-text-markup-annotations-to-pdf.md"
last_updated: "2026-06-09T10:26:34.600Z"
description: "How to add text markup annotations to a PDF using Nutrient Java SDK."
---

# Adding text markup annotations to a PDF document

Use text markup annotations to add review feedback directly on text in PDF files.

Common use cases include:

- Proofreading workflows

- Collaborative document review

- Content highlighting and emphasis

- Revision and deletion tracking

In this guide, you’ll add:

- Highlight annotations

- Underline annotations

- Strikeout annotations

- Squiggly annotations

- Custom colors for each markup type

[Download sample](https://www.nutrient.io/downloads/samples/java/add-text-markup-annotations-to-pdf.zip)

## How Nutrient helps

Nutrient Java SDK handles text markup annotation structures and appearance generation.

The SDK handles:

- Parsing text markup annotation dictionaries and quadrilateral arrays

- Managing translucent overlay rendering and blend modes

- Handling text coordinate calculations and bounding box intersections

- Complex annotation appearance streams and color transformations

## Complete implementation

This example adds multiple text markup annotations to a PDF:

```java

package io.nutrient.Sample;

import io.nutrient.sdk.Document;
import io.nutrient.sdk.types.Color;
import io.nutrient.sdk.editors.PdfEditor;
import io.nutrient.sdk.editors.pdf.pages.PdfPageCollection;
import io.nutrient.sdk.editors.pdf.pages.PdfPage;
import io.nutrient.sdk.editors.pdf.annotations.PdfAnnotationCollection;
import io.nutrient.sdk.editors.pdf.annotations.PdfHighlightAnnotation;
import io.nutrient.sdk.editors.pdf.annotations.PdfUnderlineAnnotation;
import io.nutrient.sdk.editors.pdf.annotations.PdfStrikeOutAnnotation;
import io.nutrient.sdk.editors.pdf.annotations.PdfSquigglyAnnotation;

public class TextMarkupAnnotations {

```

Create the `main` method as the sample entry point:

```java

    public static void main(String[] args) {

```

## Working with text markup annotations

Open the document with try-with-resources, create an editor, and ensure one page exists:

```java

        try (Document document = Document.open("input.pdf")) {
            PdfEditor editor = PdfEditor.edit(document);
            PdfPageCollection pages = editor.getPageCollection();

            if (pages.getCount() == 0) {
                pages.add(612.0f, 792.0f);
            }

            PdfPage page = pages.getFirst();
            PdfAnnotationCollection annotations = page.getAnnotationCollection();

```

## Adding a highlight annotation

Add a highlight with `addHighlight(x, y, width, height, author, contents)`.

In this sample:

- The position is `(50, 700)`.

- The size is `150 × 20`.

- The color is set to translucent yellow with `Color.fromArgb(128, 255, 255, 0)`.

- The alpha value `128` gives 50 percent opacity.

```java

            PdfHighlightAnnotation highlight = annotations.addHighlight(
                50.0f, 700.0f, 150.0f, 20.0f,  // x, y, width, height
                "Highlighter",
                "Important information"
            );
            // Optionally customize the color
            highlight.setColor(Color.fromArgb(128, 255, 255, 0));

```

## Adding an underline annotation

Add an underline with `addUnderline(x, y, width, height, author, contents)`.

In this sample:

- The position is `(50, 650)`.

- The size is `150 × 20`.

- The color is set to blue with `Color.fromArgb(255, 0, 0, 255)`.

```java

            PdfUnderlineAnnotation underline = annotations.addUnderline(
                50.0f, 650.0f, 150.0f, 20.0f,  // x, y, width, height
                "Underliner",
                "Emphasized text"
            );
            // Optionally customize the color
            underline.setColor(Color.fromArgb(255, 0, 0, 255));

```

## Adding a strikeout annotation

Add a strikeout with `addStrikeOut(x, y, width, height, author, contents)`.

In this sample:

- The position is `(50, 600)`.

- The size is `150 × 20`.

- The default color is red (`ARGB 255, 255, 0, 0`).

- Use this style to mark text for removal.

```java

            PdfStrikeOutAnnotation strikeOut = annotations.addStrikeOut(
                50.0f, 600.0f, 150.0f, 20.0f,  // x, y, width, height
                "Reviewer",
                "This content should be removed"
            );

```

## Adding a squiggly annotation

Add a squiggly underline with `addSquiggly(x, y, width, height, author, contents)`.

In this sample:

- The position is `(50, 550)`.

- The size is `150 × 20`.

- The color is changed to green with `Color.fromArgb(255, 0, 128, 0)`.

- Use this style to flag spelling or grammar issues.

```java

            PdfSquigglyAnnotation squiggly = annotations.addSquiggly(
                50.0f, 550.0f, 150.0f, 20.0f,  // x, y, width, height
                "Proofreader",
                "Check spelling here"
            );
            // Optionally customize the color
            squiggly.setColor(Color.fromArgb(255, 0, 128, 0));

```

## Saving the document

Save the output PDF and close the editor:

```java

            editor.saveAs("output.pdf");
            editor.close();
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

```

## Conclusion

Use this workflow to add text markup annotations:

1. Open the document and create an editor.

2. Access the page collection and ensure at least one page exists.

3. Retrieve the annotation collection for the target page.

4. Add highlight annotations with translucent overlays using `addHighlight()` for emphasizing content.

5. Customize highlight transparency using ARGB alpha values (128 = 50 percent transparency).

6. Add underline annotations with `addUnderline()` for drawing attention beneath text.

7. Add strikeout annotations with `addStrikeOut()` for marking deleted or outdated content.

8. Add squiggly annotations with `addSquiggly()` for indicating spelling or grammar issues.

9. Customize text markup colors using `setColor()` with ARGB color values.

10. Position annotations with consistent vertical spacing to create organized markup sequences.

11. Save and close the editor.

For related annotation workflows, refer to the [Java SDK guides](https://www.nutrient.io/guides/java.md).
---

## Related pages

- [Adding annotations to a PDF document](/guides/java/editor/add-annotations-to-pdf.md)
- [Adding a custom page to a PDF document](/guides/java/editor/add-custom-page-to-pdf.md)
- [Adding interactive form fields to a PDF document](/guides/java/editor/add-form-fields-to-pdf.md)
- [Adding invisible digital signatures to a PDF document](/guides/java/editor/add-invisible-signature-to-pdf.md)
- [Adding free text annotations to a PDF document](/guides/java/editor/add-freetext-annotations-to-pdf.md)
- [Adding link annotations to a PDF document](/guides/java/editor/add-link-annotations-to-pdf.md)
- [Adding shape annotations to a PDF document](/guides/java/editor/add-shape-annotations-to-pdf.md)
- [Adding stamp annotations to a PDF document](/guides/java/editor/add-stamp-annotations-to-pdf.md)
- [Adding sticky note annotations to a PDF document](/guides/java/editor/add-sticky-note-annotations-to-pdf.md)
- [Detecting and adding form fields to a PDF document](/guides/java/editor/detect-and-add-form-fields.md)
- [Adding visible digital signatures to a PDF document](/guides/java/editor/add-visible-signature-to-pdf.md)
- [Advanced digital signature workflows](/guides/java/editor/advanced-digital-signatures.md)
- [Adding redaction annotations to a PDF document](/guides/java/editor/add-redaction-annotations-to-pdf.md)
- [Editing PDF form fields](/guides/java/editor/editing-pdf-form-fields.md)
- [Editing PDF metadata with Nutrient Java SDK](/guides/java/editor/editing-pdf-metadata.md)
- [Merging PDFs](/guides/java/editor/merge-pdf-into-other-pdf.md)
- [Filling PDF form fields](/guides/java/editor/fill-pdf-form.md)
- [Nutrient Java SDK editor guides](/guides/java/editor.md)
- [Managing PDF page order](/guides/java/editor/manage-pdf-page-order.md)

