.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

PdfDocumentProcessor.RemoveFormField(String) Method

Removes an interactive form field from a document using the field name.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.2.dll

Declaration

public bool RemoveFormField(
    string name
)
Public Function RemoveFormField(
    name As String
) As Boolean
public bool RemoveFormField(
    string name
)
Public Function RemoveFormField(
    name As String
) As Boolean
public bool RemoveFormField(
    string name
)
Public Function RemoveFormField(
    name As String
) As Boolean

Parameters

Name Type Description
name String

A String which specifies the name of form field.

Parameters

Name Type Description
name String

A String which specifies the name of form field.

Parameters

Name Type Description
name String

A String which specifies the name of form field.

Returns

Type Description
Boolean

If the form field was removed from a PDF document, the value is true; otherwise, false.

Returns

Type Description
Boolean

If the form field was removed from a PDF document, the value is true; otherwise, false.

Returns

Type Description
Boolean

If the form field was removed from a PDF document, the value is true; otherwise, false.

Remarks

The RemoveFormField method tries to find the field in a document using the field name. If this field is found in the document, then it will be removed from a document and this method returns true; otherwise, it returns false.

Examples

This example shows how to remove a particular form field and a whole interactive form from a PDF document.

To remove all form fields from a document, call the PdfDocumentProcessor.RemoveForm method.

If the interactive form is removed successfully, this method returns true. If the document doesn't contain an interactive form that should be removed, this method returns false.

To remove a particular form field by its name, call the PdfDocumentProcessor.RemoveFormField method and pass a field name as an argument to this method.

The PdfDocumentProcessor.RemoveFormField method tries to find the field in a document using the field name. If this field is found in the document, then it will be removed from a document and this method returns true; otherwise, it returns false.

Imports DevExpress.Pdf
Imports System

Namespace RemoveInteractiveForm
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            Using processor As New PdfDocumentProcessor()

                ' Load a document with an interactive form.
                processor.LoadDocument("..\..\InteractiveForm.pdf")

                ' Remove a form field by its name.
                If processor.RemoveFormField("FirstName") Then

                    ' Save the modified document.
                    processor.SaveDocument("..\..\Result1.pdf")

                Else

                    ' Show a message if the form field was not found in a document.
                    Console.WriteLine("The form field was not removed from a document. Make sure, the form field exists in the document.")
                End If

                ' Remove the whole interactive form.
                If processor.RemoveForm() Then

                    ' Save the modified document.
                    processor.SaveDocument("..\..\Result2.pdf")

                Else

                    ' Show a message if the interactive form was not found in a document.
                    Console.WriteLine("The interactive form was not removed from a document. Make sure the interactive form exists in the document.")
                End If
            End Using
        End Sub
    End Class
End Namespace
See Also