A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GdPicturePDF.GetFormFieldId, GdPicturePDF.GetFormFieldChildID or methods intended to add form fields.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldReadOnly Method

GetFormFieldReadOnly Method (GdPicturePDF)

In This Topic
Returns, if the ReadOnly flag of a required form field is set. The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.

If this flag is set, then the user may not change the value of the field. Likewise, the field will not interact with the user in any way, for example, it will not respond to mouse clicks or mouse motion, etc.

Syntax
'Declaration
 
Public Function GetFormFieldReadOnly( _
   ByVal FieldId As Integer _
) As Boolean
public bool GetFormFieldReadOnly( 
   int FieldId
)
public function GetFormFieldReadOnly( 
    FieldId: Integer
): Boolean; 
public function GetFormFieldReadOnly( 
   FieldId : int
) : boolean;
public: bool GetFormFieldReadOnly( 
   int FieldId
) 
public:
bool GetFormFieldReadOnly( 
   int FieldId
) 

Parameters

FieldId
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GdPicturePDF.GetFormFieldId, GdPicturePDF.GetFormFieldChildID or methods intended to add form fields.

Return Value

true if the ReadOnly flag of the specified form field is set, otherwise false. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Example
How to determine, which form fields are read-only in the current document.
Dim caption As String = "Example: GetFormFieldReadOnly"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim message As String = ""
        If count = 0 Then
            message = "This document does not contain any forms."
        Else
            Dim formID As Integer = 0
            Dim title As String = "", messageRO As String = "ReadOnly fields:" + vbCrLf, messageREQ As String = "Required fields:" + vbCrLf
            Dim roFlag As Boolean = False, reqFlag As Boolean = False
            For i As Integer = 0 To count - 1
                formID = gdpicturePDF.GetFormFieldId(i)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    title = gdpicturePDF.GetFormFieldTitle(formID)
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        roFlag = gdpicturePDF.GetFormFieldReadOnly(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            If roFlag Then messageRO = messageRO + title + "; "
                        Else
                            message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + vbCrLf
                        End If
                        reqFlag = gdpicturePDF.GetFormFieldRequired(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            If reqFlag Then messageREQ = messageREQ + title + "; "
                        Else
                            message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + vbCrLf
                        End If
                    Else
                        message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
                    End If
                Else
                    message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
                End If
            Next
            message = messageRO + vbCrLf + vbCrLf + messageREQ + vbCrLf + vbCrLf + message + vbCrLf + "Done!"
        End If
        MessageBox.Show(message, caption)
    Else
        MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldReadOnly";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string message = "";
        if (count == 0)
            message = "This document does not contain any forms.";
        else
        {
            int formID = 0;
            string title = "", messageRO = "ReadOnly fields:\n", messageREQ = "Required fields:\n";
            bool roFlag = false, reqFlag = false;
            for (int i = 0; i < count; i++)
            {
                formID = gdpicturePDF.GetFormFieldId(i);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    title = gdpicturePDF.GetFormFieldTitle(formID);
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    {
                        roFlag = gdpicturePDF.GetFormFieldReadOnly(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        {
                            if (roFlag)
                                messageRO = messageRO + title + "; ";
                        }
                        else
                            message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + "\n";
            
                        reqFlag = gdpicturePDF.GetFormFieldRequired(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        {
                            if (reqFlag)
                                messageREQ = messageREQ + title + "; ";
                        }
                        else
                            message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + "\n";
                    }
                    else
                        message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
                }
                else
                    message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
            }
            message = messageRO + "\n\n" + messageREQ + "\n\n" + message + "\nDone!";
        }
        MessageBox.Show(message, caption);
    }
    else
        MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also