Get Signature Field Properties in C#

GdPicture.NET SDK allows you to get the properties of different form field types, including the signature form field. The most commonly used properties are the following:

Getting the Signature Field ID

To get the signature field ID, follow these steps:

  1. Load the source document with a signature field by passing its path to the LoadFromFile method of the GdPicturePDF object.

  2. Get the total number of signature fields with the GetSignatureCount method.

  3. Loop through all form fields:

If you have only one form field in a PDF document, skip the loop and use the GetFormFieldId method with 0 as its parameter to get the signature field ID:

using GdPicturePDF gdPicturePDF = new GdPicturePDF();
gdPicturePDF.LoadFromFile(@"C:\temp\output.pdf");
int signatureFieldID;
// Get the total number of form fields.
int formCount = gdPicturePDF.GetFormFieldsCount();
for (int i = 0; i <= formCount - 1; i++)
{
    // Get the current form field ID.
    int fieldID = gdPicturePDF.GetFormFieldId(i);
    // Get the current form field type.
    var fieldType = gdPicturePDF.GetFormFieldType(fieldID);
    // Check if the current form field is a signature field.
    if (fieldType == PdfFormFieldType.PdfFormFieldTypeSignature)
    {
        // Save the current form field ID as the signature field ID.
        signatureFieldID = fieldID;
    }
}
Using gdPicturePDF As GdPicturePDF = New GdPicturePDF()
    gdPicturePDF.LoadFromFile("C:\temp\output.pdf")
    Dim signatureFieldID As Integer
    ' Get the total number of form fields.
    Dim formCount As Integer = gdPicturePDF.GetFormFieldsCount()
    For i = 0 To formCount - 1
        ' Get the current form field ID.
        Dim fieldID As Integer = gdPicturePDF.GetFormFieldId(i)
        ' Get the current form field type.
        Dim fieldType = gdPicturePDF.GetFormFieldType(fieldID)
        ' Check if the current form field is a signature field.
        If fieldType Is PdfFormFieldType.PdfFormFieldTypeSignature Then
            ' Save the current form field ID as the signature field ID.
            signatureFieldID = fieldID
        End If
    Next
End Using
Used Methods

Related Topics

Getting the Signature Field Name

To get the signature field name, follow these steps:

  1. Load the source document with a signature field by passing its path to the LoadFromFile method of the GdPicturePDF object.

  2. Get the total number of signature fields with the GetSignatureCount method.

  3. Loop through all form fields:

  4. If the condition is met, use the GetFormFieldTitle method with the current form field ID as its parameter to get the signature field name.

If you have only one form field in a PDF document, skip the loop and use the GetFormFieldId method with 0 as its parameter to get the signature field ID:

using GdPicturePDF gdPicturePDF = new GdPicturePDF();
gdPicturePDF.LoadFromFile(@"C:\temp\output.pdf");
// Get the total number of form fields.
int formCount = gdPicturePDF.GetFormFieldsCount();
for (int i = 0; i <= formCount - 1; i++)
{
    // Get the current form field ID.
    int fieldID = gdPicturePDF.GetFormFieldId(i);
    // Get the current form field type.
    var fieldType = gdPicturePDF.GetFormFieldType(fieldID);
    // Check if the current form field is a signature field.
    if (fieldType == PdfFormFieldType.PdfFormFieldTypeSignature)
    {
        // Get the form field name.
        Console.WriteLine(gdPicturePDF.GetFormFieldTitle(fieldID));
    }
}
Using gdPicturePDF As GdPicturePDF = New GdPicturePDF()
    gdPicturePDF.LoadFromFile("C:\temp\output.pdf")
    ' Get the total number of form fields.
    Dim formCount As Integer = gdPicturePDF.GetFormFieldsCount()

    For i = 0 To formCount - 1
        ' Get the current form field ID.
        Dim fieldID As Integer = gdPicturePDF.GetFormFieldId(i)
        ' Get the current form field type.
        Dim fieldType = gdPicturePDF.GetFormFieldType(fieldID)
        ' Check if the current form field is a signature field.
        If fieldType Is PdfFormFieldType.PdfFormFieldTypeSignature Then
            ' Get the form field name.
            Console.WriteLine(gdPicturePDF.GetFormFieldTitle(fieldID))
        End If
    Next
End Using
Used Methods

Related Topics

Getting the Signature Field Font Name

To get the font name used in a signature field, use the GetFromFieldFontName method. This method requires the signature field ID as its parameter. Refer to the Getting the Signature Field ID section for more information.

Getting the Signature Field Font Size

To get the font size used in a signature field, use the GetFormFieldFontSize method. This method requires the signature field ID as its parameter. Refer to the Getting the Signature Field ID section for more information.

Getting the Signature Field Font Color

To get the font color used in a signature field, use the GetFormFieldFontColor method. This method requires the signature field ID as its parameter. Refer to the Getting the Signature Field ID section for more information.