AddSignatureFormField Method (GdPicturePDF)
In This Topic
Adds an empty signature form field, so called signature placeholder, on the current page of loaded PDF document according to what you have specified. A signature field is intended to be used when digitally signing a document. For further assistance, please see the Digital Signature section of the GdPicturePDF class in the Reference Guide.
You can subsequently use other methods for assigning more form field properties.
Syntax
'Declaration
Public Function AddSignatureFormField( _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As String _
) As Integer
public int AddSignatureFormField(
float ,
float ,
float ,
float ,
string
)
public function AddSignatureFormField(
: Single;
: Single;
: Single;
: Single;
: String
): Integer;
public function AddSignatureFormField(
: float,
: float,
: float,
: float,
: String
) : int;
public: int AddSignatureFormField(
float ,
float ,
float ,
float ,
string*
)
public:
int AddSignatureFormField(
float ,
float ,
float ,
float ,
String^
)
Parameters
- Left
- The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
- Top
- The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
- Width
- The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
- Height
- The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
- FieldName
- The name of the form field. It can be an empty string, but it is recommended to set a value.
Return Value
The unique identifier of the newly created empty signature form field. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to add an empty (unsigned) signature form field to the PDF document.
Dim caption As String = "AddSignatureFormField"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") = GdPictureStatus.OK) Then
Dim signatureID As Integer = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption)
Else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "AddSignatureFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") == GdPictureStatus.OK))
{
int signatureID = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption);
else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Example
How to add an empty (unsigned) signature form field to the PDF document.
Dim caption As String = "AddSignatureFormField"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") = GdPictureStatus.OK) Then
Dim signatureID As Integer = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption)
Else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "AddSignatureFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") == GdPictureStatus.OK))
{
int signatureID = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption);
else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
See Also