This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/csharp/editor/add-text-markup-annotations-to-pdf.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Add text markup annotations in C# | Nutrient .NET SDK

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

How Nutrient helps

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

The SDK handles:

  • Text markup dictionaries and quadrilateral arrays
  • Translucent overlays and blend modes
  • Coordinate calculations and bounding box intersections
  • Appearance streams and color transformations

Complete implementation

This example adds several text markup annotations to a PDF file:

using Nutrient;

Working with text markup annotations

Open the document with using statements(opens in a new tab) so resources are cleaned up after processing.

Then:

  • Create a PDF editor.
  • Get the page collection.
  • Add a letter-size page (612 × 792) if the document is empty.
  • Get the annotation collection from the first page.
try
{
using Document document = Document.Open("input.pdf");
using PdfEditor editor = PdfEditor.Edit(document);
PdfPageCollection pages = editor.PageCollection;
if (pages.Count == 0)
{
pages.Add(612.0f, 792.0f);
}
PdfPage page = pages.First ?? throw new InvalidOperationException("The document has no pages.");
PdfAnnotationCollection annotations = page.AnnotationCollection;

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.
PdfHighlightAnnotation highlight = annotations.AddHighlight(
50.0f, 700.0f, 150.0f, 20.0f, // x, y, width, height
"Highlighter",
"Important information"
);
// Optionally customize the color
highlight.Color = 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).
PdfUnderlineAnnotation underline = annotations.AddUnderline(
50.0f, 650.0f, 150.0f, 20.0f, // x, y, width, height
"Underliner",
"Emphasized text"
);
// Optionally customize the color.
underline.Color = 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.
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.
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.Color = Color.FromArgb(255, 0, 128, 0);

Saving the document

Save the output PDF.

The catch block catches NutrientException if processing fails:

editor.SaveAs("output.pdf");
Console.WriteLine("Successfully saved output.pdf");
}
catch (NutrientException e)
{
Console.Error.WriteLine($"Error: {e.Message}");
Environment.Exit(1);
}

Conclusion

Use this workflow to add text markup annotations:

  1. Open the document with using statements for automatic resource cleanup.
  2. Create an editor and access the page collection.
  3. Ensure at least one page exists by adding a letter-size page if needed.
  4. Retrieve the annotation collection from the target page.
  5. Add highlight annotations with translucent overlays using AddHighlight() for emphasizing content.
  6. Customize highlight transparency using ARGB alpha values (128 = 50 percent transparency).
  7. Add underline annotations with AddUnderline() for drawing attention beneath text.
  8. Add strikeout annotations with AddStrikeOut() for marking deleted or outdated content.
  9. Add squiggly annotations with AddSquiggly() for indicating spelling or grammar issues.
  10. Customize text markup colors using the Color property with ARGB color values.
  11. Position annotations with consistent vertical spacing to create organized markup sequences.
  12. Save the document — the using statements release the native handles.

For related annotation workflows, refer to the .NET SDK annotation guides.