# pdf-viewer-annotations

> PDF viewer pre-populated with highlight and underline annotations on page one.

**Framework:** aspnet-mvc  **Component:** PdfViewer  **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/aspnet-mvc/pdf-viewer-annotations.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.PdfViewer
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- 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.cshtml

```cshtml
@using Syncfusion.EJ2
@{
    ViewData["Title"] = "Annotations";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    string serviceUrl = VirtualPathUtility.ToAbsolute("~/api/PdfViewer/");
}

@section ControlsSection{
    <div class="control-section">
         @Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/annotations-v2.pdf").ResourceUrl("https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib").DocumentLoad("documentLoad").DownloadEnd("documentLoad").IsCommandPanelOpen(true).IsAnnotationToolbarVisible(true).Render()
    </div>
}
@*custom code start*@
<style>

#pdfviewer {
    display: block;
    height: 641px;
}

</style>
@*custom code end*@
<script>

    function documentLoad(arg) {
        var viewer = document.getElementById('pdfviewer').ej2_instances[0];
        if (arg.documentName === 'annotations-v2.pdf') {
            viewer.annotation.addAnnotation("Highlight", {
                bounds: [{ x: 97, y: 610, width: 340, height: 14 }],
                pageNumber: 1
            });
            viewer.annotation.addAnnotation("Underline", {
                bounds: [{ x: 97, y: 705, width: 346, height: 14 }],
                pageNumber: 1
            });
            viewer.annotation.addAnnotation("Strikethrough", {
                bounds: [{ x: 97, y: 800, width: 367, height: 14 }],
                pageNumber: 1
            });
            viewer.annotation.addAnnotation("Squiggly", {
                bounds: [{ x: 97, y: 895.5, width: 336, height: 14 }],
                pageNumber: 1
            });
        
        }
    }
    function change(args) {
        var viewer = document.getElementById('pdfviewer').ej2_instances[0];
        if (args.checked) {
            viewer.serviceUrl = '';
        } else {
            viewer.serviceUrl = '@serviceUrl';
        }
        viewer.dataBind();
        viewer.load(viewer.documentPath, null);
    }

</script>

```

### src/components/pdf-viewer-annotations/PdfViewerController.cs

```cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EJ2MVCSampleBrowser.Controllers.PdfViewer
{
    public partial class PdfViewerController : Controller
    {
        public ActionResult Annotations()
        {
            return View("~/Views/Home/pdf-viewer/annotations/PdfViewer.cshtml");
        }
    }
}
```
