# pdf-viewer-annotations

> Pdf viewer adds highlight, underline, free text, and stamp annotations on top of a remote PDF.

**Framework:** maui  **Component:** pdf-viewer  **Variant:** annotations

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/maui/pdf-viewer-annotations.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Maui.PdfViewer
```

**Notes**

- Syncfusion release: 2026 Volume 2 (v34.1.29)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/pdf-viewer-annotations/PdfViewer.xaml

```xaml
﻿<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer"
             x:Class="MAUI.MainPage"
             Title="Annotations"
             BackgroundColor="White">

    <Grid>
        <syncfusion:SfPdfViewer x:Name="PdfViewer"
                                ShowToolbars="True"
                                ShowScrollHead="True"
                                EnableTextSelection="True"
                                IsCommentsPanelVisible="True"
                                IsOutlineViewVisible="True"
                                DocumentLoaded="OnDocumentLoaded" />
    </Grid>

</ContentPage>

```

### src/components/pdf-viewer-annotations/PdfViewer.xaml.cs

```cs
﻿using Microsoft.Maui.Graphics;
using Syncfusion.Maui.PdfViewer;

namespace MAUI;

public partial class MainPage : ContentPage
{
    private const string DocumentUrl =
        "https://cdn.syncfusion.com/content/pdf/annotations-v2.pdf";

    public MainPage()
    {
        InitializeComponent();
        _ = LoadDocumentAsync();
    }

    private async Task LoadDocumentAsync()
    {
        try
        {
            using var http = new HttpClient();
            var bytes = await http.GetByteArrayAsync(DocumentUrl);
            var stream = new MemoryStream(bytes);
            PdfViewer.LoadDocument(stream);
        }
        catch (Exception ex)
        {
            await DisplayAlertAsync("Error", $"Failed to load document: {ex.Message}", "OK");
        }
    }

    private void OnDocumentLoaded(object? sender, EventArgs e)
    {
        AddTextMarkupAnnotations();
        AddLineAndArrowAnnotations();
        AddMeasurementAnnotations();
        AddFreeTextAndStampAnnotations();
        AddStickyNoteAnnotations();
    }

    private void AddTextMarkupAnnotations()
    {
        PdfViewer.AddAnnotation(new HighlightAnnotation(1, new List<RectF>
        {
            new RectF(70, 455, 340, 14)
        }));

        PdfViewer.AddAnnotation(new UnderlineAnnotation(1, new List<RectF>
        {
            new RectF(70, 525, 346, 14)
        }));

        PdfViewer.AddAnnotation(new StrikeOutAnnotation(1, new List<RectF>
        {
            new RectF(70, 598, 367, 14)
        }));

        PdfViewer.AddAnnotation(new SquigglyAnnotation(1, new List<RectF>
        {
            new RectF(70, 670.5f, 336, 14)
        }));
    }

    private void AddLineAndArrowAnnotations()
    {
        PdfViewer.AddAnnotation(new LineAnnotation(
            new[] { 90f, 160f, 350f, 170f }, 2, LineEndingStyle.None));

        PdfViewer.AddAnnotation(new LineAnnotation(
            new[] { 90f, 270f, 350f, 270f }, 2, LineEndingStyle.Open));

        PdfViewer.AddAnnotation(new SquareAnnotation(
            new RectF(90, 360, 150, 75), 2));

        PdfViewer.AddAnnotation(new CircleAnnotation(
            new RectF(90, 450, 90, 90), 2));

        PdfViewer.AddAnnotation(new PolygonAnnotation(new List<PointF>
        {
            new PointF(90, 600),
            new PointF(132, 571),
            new PointF(179, 599),
            new PointF(168, 642),
            new PointF(101, 642)
        }, 2));
    }

    private void AddMeasurementAnnotations()
    {
        PdfViewer.AddAnnotation(new PolylineAnnotation(new List<PointF>
        {
            new PointF(200, 260), new PointF(350, 260)
        }, 3));

        PdfViewer.AddAnnotation(new PolylineAnnotation(new List<PointF>
        {
            new PointF(200, 250), new PointF(285, 250), new PointF(286, 312)
        }, 3));

        PdfViewer.AddAnnotation(new PolygonAnnotation(new List<PointF>
        {
            new PointF(200, 350), new PointF(288, 349), new PointF(289, 403)
        }, 3));

        PdfViewer.AddAnnotation(new CircleAnnotation(new RectF(200, 460, 90, 90), 3));

        PdfViewer.AddAnnotation(new PolygonAnnotation(new List<PointF>
        {
            new PointF(200, 610),
            new PointF(200, 719),
            new PointF(320, 719),
            new PointF(320, 609)
        }, 3));
    }

    private void AddFreeTextAndStampAnnotations()
    {
        PdfViewer.AddAnnotation(new FreeTextAnnotation(
            "Syncfusion",
            4,
            new RectF(250, 60, 200, 40))
        { FontSize = 16 });

        PdfViewer.AddAnnotation(new StampAnnotation(
            StampType.Approved, 4, new PointF(200, 220)));

        PdfViewer.AddAnnotation(new StampAnnotation(
            StampType.Confidential, 4, new PointF(200, 450)));
    }

    private void AddStickyNoteAnnotations()
    {
        PdfViewer.AddAnnotation(new StickyNoteAnnotation(
            StickyNoteIcon.Note,
            string.Empty,
            6,
            new PointF(300, 320)));
    }
}

```
