VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    PDF: Remove field from PDF interactive form
    In This Topic
    The form field can be removed using PdfDocumentInteractiveForm.RemoveField method in case the full name of field is known. The method removes the field, its child fields and all fields annotations.

    Also the field can be removed using PdfInteractiveFormField.Remove method. The method removes the field, its child fields and all fields annotations.

    Here is C#/VB.NET code that demonstrates how to remove field using field name from PDF interactive form:
    /// <summary>
    /// Removes an interactive field from interactive form of PDF document.
    /// </summary>
    /// <param name="pdfFilename">The filename of PDF document.</param>
    /// <param name="fullyQualifiedFieldName">The name of field.</param>
    public static void RemoveFieldFromPdfInteractiveForm(string pdfFilename, string fullyQualifiedFieldName)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document =
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // if PDF document has interactive form
            if (document.InteractiveForm != null)
            {
                // get reference to the interactive form
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm form = document.InteractiveForm;
    
                // remove field from interactive form
                form.RemoveField(fullyQualifiedFieldName);
    
                // save changes to a file
                document.SaveChanges();
            }
        }
    }
    
    ''' <summary>
    ''' Removes an interactive field from interactive form of PDF document.
    ''' </summary>
    ''' <param name="pdfFilename">The filename of PDF document.</param>
    ''' <param name="fullyQualifiedFieldName">The name of field.</param>
    Public Shared Sub RemoveFieldFromPdfInteractiveForm(pdfFilename As String, fullyQualifiedFieldName As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
            ' if PDF document has interactive form
            If document.InteractiveForm IsNot Nothing Then
                ' get reference to the interactive form
                Dim form As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm = document.InteractiveForm
    
                ' remove field from interactive form
                form.RemoveField(fullyQualifiedFieldName)
    
                ' save changes to a file
                document.SaveChanges()
            End If
        End Using
    End Sub