GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / RemoveFormFields Method
Example





In This Topic
RemoveFormFields Method (GdPicturePDF)
In This Topic
Removes all form fields included in the currently loaded PDF document.
Syntax
'Declaration
 
Public Function RemoveFormFields() As GdPictureStatus
public GdPictureStatus RemoveFormFields()
public function RemoveFormFields(): GdPictureStatus; 
public function RemoveFormFields() : GdPictureStatus;
public: GdPictureStatus RemoveFormFields(); 
public:
GdPictureStatus RemoveFormFields(); 

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to remove all form fields included in the current document.
Dim caption As String = "Example: RemoveFormFields"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
    If gdpicturePDF.RemoveFormFields() = GdPictureStatus.OK Then
        Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            If gdpicturePDF.SaveToFile("forms_removed.pdf") = GdPictureStatus.OK Then
                MessageBox.Show("Number of form fields: " + count.ToString() + vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
            Else
                MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The RemoveFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveFormFields";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    if (gdpicturePDF.RemoveFormFields() == GdPictureStatus.OK)
    {
        int count = gdpicturePDF.GetFormFieldsCount();
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            if (gdpicturePDF.SaveToFile("forms_removed.pdf") == GdPictureStatus.OK)
                MessageBox.Show("Number of form fields: " + count.ToString() + "\nThe example has been followed successfully and the file has been saved.", caption);
            else
                MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The RemoveFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
See Also