Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / RemoveXFAFormFieldsData Method

RemoveXFAFormFieldsData Method (GdPicturePDF)

In This Topic
Removes XFA form fields data resource for all form fields in currently loaded PDF document.

XFA stands for XML Forms Architecture, which is Adobe’s proprietary XML-based form technology and it has not been standardized in any public specification. With introducing the first version of PDF 2.0 as ISO-32000-2 published in May 2017, XFA entries have been officially excluded from this specification Therefore this format is not supported by GdPicturePDF and we will never support it in the future as well.

Please note that you may encounter potential rendering problems when viewing a PDF document with XFA forms using GdPicturePDF. Probably you will see this fallback message introduced by Adobe: "If this message is not eventually replaced by the proper content of the document, your PDF viewer may not be able to display this type of document."

Syntax
'Declaration
 
Public Function RemoveXFAFormFieldsData() As GdPictureStatus
public GdPictureStatus RemoveXFAFormFieldsData()
public function RemoveXFAFormFieldsData(): GdPictureStatus; 
public function RemoveXFAFormFieldsData() : GdPictureStatus;
public: GdPictureStatus RemoveXFAFormFieldsData(); 
public:
GdPictureStatus RemoveXFAFormFieldsData(); 

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Remarks
This method is only allowed for use with non-encrypted documents.

This method is useful only in scenarios where the document contains standard AcroForm form fields with additional XFA resource. If the document is purely XFA based document this method will lead to loss of the document contents.

Please be aware that we do not support this format now and we will never support it in the future as it is not standardized and has been excluded from the PDF Reference.

Example
How to find out if the PDF document contains XFA forms and remove the data.
Dim caption As String = "Example: RemoveXFAFormFieldsData"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
    Dim hasXFA As Boolean = gdpicturePDF.HasXFAFormFields()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If hasXFA Then
            If gdpicturePDF.RemoveXFAFormFieldsData() = GdPictureStatus.OK Then
                MessageBox.Show("XFA form fields data has been successfully remove from the document.", caption)
            Else
                MessageBox.Show("The RemoveXFAFormFieldsData() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("This PDF document contains NO XFA forms.", caption)
        End If
    Else
        MessageBox.Show("The HasXFAFormFields() 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: RemoveXFAFormFieldsData";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    bool hasXFA = gdpicturePDF.HasXFAFormFields();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if (hasXFA)
        {
            if(gdpicturePDF.RemoveXFAFormFieldsData() == == GdPictureStatus.OK)
            {
                MessageBox.Show("XFA form fields data has been successfully remove from the document.", caption)
            }
            else
            {
                MessageBox.Show("The RemoveXFAFormFieldsData() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
            }
        }
        else
        {
            MessageBox.Show("This PDF document contains NO XFA forms.", caption);
        }
    }
    else
        MessageBox.Show("The HasXFAFormFields() 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