# pdf-viewer-form-filling

> PDF viewer demonstrating interactive form fields for entering and reviewing document data.

**Framework:** aspnet-mvc  **Component:** PdfViewer  **Variant:** form-filling

## 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-form-filling.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-form-filling/PdfViewer.cshtml

```cshtml
@using Syncfusion.EJ2

@{
    ViewData["Title"] = "Form Filling";
    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/form-filling-document.pdf").ResourceUrl("https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib").ValidateFormFields("validateFormFields").EnableFormFieldsValidation(true).ShowNotificationDialog(false).Render()
    </div>
}

<style>
   
#pdfviewer {
    display: block;
    height: 641px;
}

</style>
@*custom code end*@
<script>
    function validateFormFields(args) {
        var viewer = document.getElementById('pdfviewer').ej2_instances[0];
        var errorMessage = "Required Field(s): ";
        var forms = viewer.formFieldCollections;
        var flag = false;
        var radioGroupName = "";
        for (var i = 0; i < forms.length; i++) {
            var text = "";
            if (forms[i].isRequired == true) {
                if (forms[i].type.toString() == "Checkbox" && forms[i].isChecked == false) {
                    text = forms[i].name;
                }
                else if (forms[i].type == "RadioButton" && flag == false) {
                    radioGroupName = forms[i].name;
                    if (forms[i].isSelected == true)
                        flag = true;
                }
                else if (forms[i].type.toString() != "Checkbox" && forms[i].type != "RadioButton" && forms[i].value == "") {
                    text = forms[i].name;
                }
                if (text != "") {
                    if (errorMessage == "Required Field(s): ") {
                        errorMessage += text;
                    }
                    else {
                        errorMessage += ", " + text;
                    }
                }
            }
        }
        if (!flag && radioGroupName != "") {
            if (errorMessage == "Required Field(s): ")
                errorMessage += radioGroupName;
            else
                errorMessage += ", " + radioGroupName;
        }
        if (errorMessage != "Required Field(s): ") {
            viewer.showNotificationPopup(errorMessage);
        }
    }
    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-form-filling/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 FormFilling()
        {
            return View("~/Views/Home/pdf-viewer/form-filling/PdfViewer.cshtml");
        }
    }
}
```
