HelpBot Assistant

How can I help you?

Remove PDF Form Fields from a PDF in MVC

11 Feb 20262 minutes to read

Remove Form Fields Using the UI

Steps:

  1. Enable Form Designer mode.
  2. Select the form field.
  3. Click Delete in the toolbar or press the Delete key.
    Form Designer toolbar with Delete icon

Remove Form Fields Programmatically

Use deleteFormField() with a field reference or ID.

<button id="deleteAllFields">Delete Form Fields</button>
<button id="deleteById">Delete First Field By ID</button>
<div style="width:100%;height:600px">
        @Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf").Render()
    </div>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];
        document.getElementById('deleteAllFields').addEventListener('click', function () {
            var fields = pdfviewer.formFieldCollections.slice();
            fields.forEach(function (field) { pdfviewer.formDesignerModule.deleteFormField(field); });
        });
        document.getElementById('deleteById').addEventListener('click', function () {
            if (pdfviewer.formFieldCollections.length > 0) {
                var id = pdfviewer.formFieldCollections[0].id;
                if (id) {
                    pdfviewer.formDesignerModule.deleteFormField(id);
                }
            }
        });
    });
</script>

View Sample on GitHub

See also