AddSignatureField

Declaration

Delphi

function AddSignatureField(FieldName: WideString; Biodata: WideString; const Name, Reason, Location, Contact, AlternateName, Misc WideString;  showNameAndDate: WordBool):Integer;

ActiveX

HRESULT _stdcall AddSignatureField([in] BSTR FieldName, [in] BSTR Biodata, [in] BSTR Name, [in] BSTR Reason, [in] BSTR Location, [in] BSTR Contact, [in] BSTR AlternateName, [in] BSTR Misc, [in] VARIANT_BOOL ShowNameAndDate, [out, retval] long* RetVal); 

 

Description

By using this method you can add a signature to existing (empty) signature fields, which are already inside the document. Other than with AddSignature, you don´t need to define the positions, instead the signature is found by the field name. 

 AddSignatureField will force you to confirm the document hash on the device, to disable that you can enable the Emulation Mode (see Driver Options).


AddSignatureField required the 4 Callback Event (OnGetAesKey, OnGetDeviceCertificate, OnGetSignedDocHash, OnReadHighResBitmap). Without them adding a Signature into a PDF is not possible.



Arguments

ArgumentDescription
FieldName

FieldName is the Name of the signature field, in which the signature should be added.

Name

Name is the name of the signer. This is added to the signature details and the optional stamp.

Reason

Reason is the reason of signing and will also be added into the signature details and the stamp.

Location

Location is the loaction of signing. Signature details and stamp.

Contact

Contact is the contact of signing. This will also only be added to the signature details, but not to the stamp.

AlternateName

This value is for future use, use an empty string.

Misc

This value is for future use, use an empty string.

Biodata

Biodata is the biodata of the signature, which you can get from the freeware deviceAPI (GetBiodataString or peekBiodataString).

showNameAndDate

ShowNameAndDate is used to embed the stamp under the signature. It contains the name, reason and time and is visible in the document and also in the signature details.


Return value

AddSignatureField returns the following integer values:

 

ValueMeaning
-29signature field is to small, height and width needs to be higher an 20
-28failure in imagestream from pad
-27the four needed events are not defined
-26the signatureimage is wrong
-25image file extention unknown
-24image file not exisiting
-23Image buffer is nil or size is 0
-22document is sealed oder hash is encrypted with unknown key
-21document erroneous
-20no document is loaded
-12temp file hash is incorrect
-11

No key(s)*

-10

Seal required*

-5Exception occured
-4Timeserver access error
-3Signing will be repeated
-2Signing was cancelled
-1Signature was not added to the document, because of an error
0

Unspecified result

1

Signature was successful added to the document

*obsolete

Calculation of the PDF coordinates

The top/left has the value 0/0 and for the calculation you can use the following formula:

 

A4= 8.27 x 11.69 inch with 72points/inch = 595x842 points

1 point = 0.03527777778 centimeters

1 point = 0.01388888889 inch

Example: 5cm are 142 points (5cm / 0.03527777778 = 141,7323)

 

Samples

C# - AddSignature
// Set device parameters
 
SignAPIv4.DeviceModel = SigDev.GetDriverString(0);
SignAPIv4.DeviceSerial = SigDev.GetDriverString(1); 
          
// Get biodata from device
             
string bd = "";
SigDev.peekBiodataString(ref bd);
            
// Add signature to document
           
int x1 = 100; 
int x2 = 250; 
int y1 = 100; 
int y2 = 200; 
int page = 1;
string signer = "John Doe";
string reason = "I agree with the content.";
bool showStamp = true;
 
int addResult = SignAPIv4.AddSignature(page, x1, y1, x2, y2, signer, reason, bd, showStamp);

switch(addResult)
{  
	case -11:	MessageBox.Show("No key(s).");
        		break;
                
	case -10: 	MessageBox.Show("Seal required.");
         		break;                     
       
 	case -3: 	MessageBox.Show("Repeat.");
         		break;    
              
 	case -2: 	MessageBox.Show("Cancelled.");			
         		break;                    
                
	case -1: 	MessageBox.Show("Error.");               
         		break;
                
	case 0: 	MessageBox.Show("Unspecified result.");                			
         		break;                      
                
 	case 1: 	MessageBox.Show("Succeeded.");                
         		break;
}

 

vb.net - AddSignature
'Set device parameters
'DeviceModel : This Property must be Set by the client application before calling AddSignature. 

SignatureAPI4.DeviceModel = SignatureDevice.GetDriverString(0)
SignatureAPI4.DeviceSerial = SignatureDevice.GetDriverString(1)  
 
'Get the biodata from the device
Dim bd As String = ""
SignatureDevice.peekBiodataString(bd)

Dim page, x1, y1, x2, y2, addResult As Integer
page = 1
x1 = 100
x2 = 250 
y1 = 100 
y2 = 200 
addResult = SignatureAPI4.AddSignature(page, x1, y1, x2, y2, "Name", "Reason", bd, True)

Select Case (addResult)

	Case -11
			MessageBox.Show("No key.")

	Case -10
			MessageBox.Show("Seal required.")

	Case -3
			MessageBox.Show("Repeat.")

	Case -2
			MessageBox.Show("Cancelled.")

	Case -1
			MessageBox.Show("Error.")

	Case 0
			MessageBox.Show("Unspecified result.")

	Case 1
			MessageBox.Show("Succeeded.")

End Select

 

Delphi- AddSignature
    SOPad.getBiodataString(Biodata);
    if Biodata <> '' then
    begin
        SOAPI4.DeviceModel  := SOPad.GetDriverString(0);
        SOAPI4.DeviceSerial := SOPad.GetDriverString(1);

        SOAPI4.SetDynamicStampText('Signed by: Mr. X<br>Reason: <b>Conformation of the Contract</b> if Contract<br>Time: <i>' + FormatDateTime('c',Now) +'</i>');

        SOAPI4.TimeCenterURL := 'http://stepoverinfo.net:88/tsa/'; // use empty string '' for no timeserver

        SOAPI4.addSignature(1, 100, 100, 250, 200, 'Mr X', 'Conformation', Biodata, True);
	end;

 

C# - AddSignatureField
// Set device parameters
 
SignAPIv4.DeviceModel = SigDev.GetDriverString(0);
SignAPIv4.DeviceSerial = SigDev.GetDriverString(1); 
          
// Get biodata from device
             
string bd = "";

SigDev.peekBiodataString(ref bd);
            
// add the signature to the field "Unterschrift1" which already exist inside the PDF
 
string fieldName = "Unterschrift1";
string signer = "John Doe";
string reason = "I agree with the content.";
string location = "Stuttgart";
string contact = "John Doe";
string alternateName = "";
string misc = "";
bool showStamp = false;
 
int addResult = SignAPIv4.AddSignatureField(fieldName, bd, signer, reason, location, contact, alternateName, misc, showStamp);

 
switch(addResult)
{  
	case -11:	MessageBox.Show("No key(s).");
        		break;
                
	case -10: 	MessageBox.Show("Seal required.");
         		break;                     
       
 	case -3: 	MessageBox.Show("Repeat.");
         		break;    
              
 	case -2: 	MessageBox.Show("Cancelled.");			
         		break;                    
                
	case -1: 	MessageBox.Show("Error.");               
         		break;
                
	case 0: 	MessageBox.Show("Unspecified result.");                			
         		break;                      
                
 	case 1: 	MessageBox.Show("Succeeded.");                
         		break;
}
vb.NET - AddSignatureImage
'Set device parameters
'DeviceModel : This Property must be Set by the client application before calling AddSignature. 

SignatureAPI4.DeviceModel = SignatureDevice.GetDriverString(0)
SignatureAPI4.DeviceSerial = SignatureDevice.GetDriverString(1)  
 
'Get the biodata from the device
Dim bd,  As String = ""
SignatureDevice.peekBiodataString(bd)

addResult = SignatureAPI4.AddSignatureField(fieldName, bd, "Signer", "Reason", "Location", "Contact", "", "", True)
 
Select Case (addResult)

	Case -11
		MessageBox.Show("No key.")

	Case -10
		MessageBox.Show("Seal required.")

	Case -3
		MessageBox.Show("Repeat.")

	Case -2
		MessageBox.Show("Cancelled.")

	Case -1
		MessageBox.Show("Error.")

	Case 0
		MessageBox.Show("Unspecified result.")

	Case 1
		MessageBox.Show("Succeeded.")

End Select