GetSignatureProperties Method (GdPicturePDF)
In This Topic
Retrieves available information about the applied digital signature specified by its index in the currently loaded PDF document, as well as about the used certificate (digital ID).
This method also checks the certificate validity and if the document has been altered or corrupted since it was signed.
Syntax
'Declaration
Public Function GetSignatureProperties( _
ByVal As Integer, _
ByRef As String, _
ByRef As String, _
ByRef As String, _
ByRef As String, _
ByRef As String, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single, _
ByRef As Integer, _
ByRef As Boolean, _
ByRef As Boolean, _
ByRef As String, _
ByRef As String, _
ByRef As Date, _
ByRef As Date, _
ByRef As String, _
ByRef As Integer, _
ByRef As Date, _
ByRef As PdfSignatureCertificationLevel _
) As GdPictureStatus
public GdPictureStatus GetSignatureProperties(
int ,
ref string ,
ref string ,
ref string ,
ref string ,
ref string ,
ref float ,
ref float ,
ref float ,
ref float ,
ref int ,
ref bool ,
ref bool ,
ref string ,
ref string ,
ref DateTime ,
ref DateTime ,
ref string ,
ref int ,
ref DateTime ,
ref PdfSignatureCertificationLevel
)
public function GetSignatureProperties(
: Integer;
var : String;
var : String;
var : String;
var : String;
var : String;
var : Single;
var : Single;
var : Single;
var : Single;
var : Integer;
var : Boolean;
var : Boolean;
var : String;
var : String;
var : DateTime;
var : DateTime;
var : String;
var : Integer;
var : DateTime;
var : PdfSignatureCertificationLevel
): GdPictureStatus;
public function GetSignatureProperties(
: int,
: String,
: String,
: String,
: String,
: String,
: float,
: float,
: float,
: float,
: int,
: boolean,
: boolean,
: String,
: String,
: DateTime,
: DateTime,
: String,
: int,
: DateTime,
: PdfSignatureCertificationLevel
) : GdPictureStatus;
public: GdPictureStatus GetSignatureProperties(
int ,
ref string* ,
ref string* ,
ref string* ,
ref string* ,
ref string* ,
ref float ,
ref float ,
ref float ,
ref float ,
ref int ,
ref bool ,
ref bool ,
ref string* ,
ref string* ,
ref DateTime ,
ref DateTime ,
ref string* ,
ref int ,
ref DateTime ,
ref PdfSignatureCertificationLevel
)
public:
GdPictureStatus GetSignatureProperties(
int ,
String^% ,
String^% ,
String^% ,
String^% ,
String^% ,
float% ,
float% ,
float% ,
float% ,
int% ,
bool% ,
bool% ,
String^% ,
String^% ,
DateTime% ,
DateTime% ,
String^% ,
int% ,
DateTime% ,
PdfSignatureCertificationLevel%
)
Parameters
- SignatureIdx
- The signature index. It must be a value from 0 to GetSignatureCount-1.
- SignatureName
- Output parameter. The name of the person or authority signing the document. Since it is an optional information, the returned value can be an empty string.
- SignatureReason
- Output parameter. The reason for the signing the document. Since it is an optional information, the returned value can be an empty string.
- SignatureLocation
- Output parameter. The CPU host name or physical location of the signing. Since it is an optional information, the returned value can be an empty string.
- SignatureContactInfo
- Output parameter. Information provided by the signer to enable a recipient to contact the signer to verify the signature,
for example a phone number. Since it is an optional information, the returned value can be an empty string.
- SignatureDate
- Output parameter. The time of signing as a string. Depending on the signature handler, this may be a normal unverified computer time or a time
generated in a verifiable way from a secure time server.
- StampLeft
- Output parameter. The horizontal (X) coordinate of the closest point to the currently defined origin, where the signature is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the page, where the signature is situated.
- StampTop
- Output parameter. The vertical (Y) coordinate of the closest point to the currently defined origin, where the signature is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the page, where the signature is situated.
- StampWidth
- Output parameter. The width of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
If the returned value is 0, the signature is invisible.
- StampHeight
- Output parameter. The height of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
If the returned value is 0, the signature is invisible.
- StampPage
- Output parameter. The number of the page, on which the signature is placed.
- DocumentValid
- Output parameter. true, if the document has been altered or corrupted since it was signed, otherwise false.
- CertificateValid
- Output parameter. true, if the used certificate (digital ID) has been successfully verified, otherwise false.
- CertificateFriendlyName
- Output parameter. The associated alias of the used certificate, that means the name of the certificate's owner.
- CertificateIssuer
- Output parameter. The name of the authority that issued the used certificate.
- CertificateNotBefore
- Output parameter. The earliest time and date on which the used certificate is valid.
- CertificateNotAfter
- Output parameter. The time and date past which the used certificate is no longer valid.
- CertificateSubject
- Output parameter. The entity the used certificate belongs to, for example an individual or an organization.
- CertificateVersion
- Output parameter. The version of the used certificate.
- SigningTime
- Output parameter. The date and time when the document has been signed. This value should be used only when the time of signing is not available in the signature.
- SignatureLevel
- Output parameter. A member of the PdfSignatureCertificationLevel enumeration. The used level of the signature certification.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to retrieve and show properties of the first signature of the PDF document.
Dim caption As String = "GetSignatureProperties"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_signed.pdf", False)
If status = GdPictureStatus.OK Then
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If signatureCount > 0 Then
Dim sigName As String = "", sigReason As String = "", sigLocation As String = "", sigInfo As String = "", sigDate As String = "",
certFriendName As String = "", certIssuer As String = "", certSubject As String = ""
Dim stampLeft As Single = 0, stampTop As Single = 0, stampWidth As Single = 0, stampHeight As Single = 0
Dim stampPage As Integer = 0, certVersion As Integer = 0
Dim docValid As Boolean = False, certValid As Boolean = False
Dim certNotBefore As New DateTime(), certNotAfter As New DateTime(), sigTime As New DateTime()
Dim sigLevel As PdfSignatureCertificationLevel = PdfSignatureCertificationLevel.NotCertified
status = gdpicturePDF.GetSignatureProperties(0, sigName, sigReason, sigLocation, sigInfo, sigDate,
stampLeft, stampTop, stampWidth, stampHeight, stampPage,
docValid, certValid, certFriendName, certIssuer, certNotBefore, certNotAfter, certSubject, certVersion, sigTime, sigLevel)
If status = GdPictureStatus.OK Then
Dim message As String = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString()
If (stampWidth = 0) OrElse (stampHeight = 0) Then
message = message + ", the signature is invisible,"
Else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString()
End If
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:" + vbCrLf
If docValid Then
message = message + "The document has not been changed after signing." + vbCrLf
Else
message = message + "The document has been changed after signing." + vbCrLf
End If
If certValid Then
message = message + "The signature is valid." + vbCrLf
Else
message = message + "The signature is not valid." + vbCrLf
End If
message = message + "Signature Info:" + vbCrLf + " Name: " + sigName + vbCrLf + " Reason: " + sigReason + vbCrLf + " Location: " + sigLocation + vbCrLf + " Contact info: " + sigInfo + vbCrLf + " Date: " + sigDate + vbCrLf +
"Certificate Info:" + vbCrLf + " Name: " + certFriendName + vbCrLf + " Issuer: " + certIssuer + vbCrLf + " Subject: " + certSubject + vbCrLf + " Version: " + certVersion + vbCrLf + " Time: " + sigTime.ToString() + vbCrLf +
"Certificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + "."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption)
End If
Else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "GetSignatureProperties";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_signed.pdf", false);
if (status == GdPictureStatus.OK)
{
int signatureCount = gdpicturePDF.GetSignatureCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (signatureCount > 0)
{
string sigName = "", sigReason = "", sigLocation = "", sigInfo = "", sigDate = "", certFriendName = "", certIssuer = "", certSubject = "";
float stampLeft = 0, stampTop = 0, stampWidth = 0, stampHeight = 0;
int stampPage = 0, certVersion = 0;
bool docValid = false, certValid = false;
DateTime certNotBefore = new DateTime(), certNotAfter = new DateTime(), sigTime = new DateTime();
PdfSignatureCertificationLevel sigLevel = PdfSignatureCertificationLevel.NotCertified;
status = gdpicturePDF.GetSignatureProperties(0, ref sigName, ref sigReason, ref sigLocation, ref sigInfo, ref sigDate,
ref stampLeft, ref stampTop, ref stampWidth, ref stampHeight, ref stampPage,
ref docValid, ref certValid, ref certFriendName, ref certIssuer,
ref certNotBefore, ref certNotAfter, ref certSubject, ref certVersion, ref sigTime, ref sigLevel);
if (status == GdPictureStatus.OK)
{
string message = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString();
if ((stampWidth == 0) || (stampHeight == 0))
message = message + ", the signature is invisible,";
else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString();
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:\n";
if (docValid)
message = message + "The document has not been changed after signing.\n";
else
message = message + "The document has been changed after signing.\n";
if (certValid)
message = message + "The signature is valid.\n";
else
message = message + "The signature is not valid.\n";
message = message + "Signature Info:\n Name: " + sigName + "\n Reason: " + sigReason + "\n Location: " + sigLocation + "\n Contact info: " + sigInfo + "\n Date: " + sigDate +
"\nCertificate Info:\n Name: " + certFriendName + "\n Issuer: " + certIssuer + "\n Subject: " + certSubject + "\n Version: " + certVersion + "\n Time: " + sigTime.ToString() +
"\nCertificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + ".";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption);
}
else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Example
How to retrieve and show properties of the first signature of the PDF document.
Dim caption As String = "GetSignatureProperties"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_signed.pdf", False)
If status = GdPictureStatus.OK Then
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If signatureCount > 0 Then
Dim sigName As String = "", sigReason As String = "", sigLocation As String = "", sigInfo As String = "", sigDate As String = "",
certFriendName As String = "", certIssuer As String = "", certSubject As String = ""
Dim stampLeft As Single = 0, stampTop As Single = 0, stampWidth As Single = 0, stampHeight As Single = 0
Dim stampPage As Integer = 0, certVersion As Integer = 0
Dim docValid As Boolean = False, certValid As Boolean = False
Dim certNotBefore As New DateTime(), certNotAfter As New DateTime(), sigTime As New DateTime()
Dim sigLevel As PdfSignatureCertificationLevel = PdfSignatureCertificationLevel.NotCertified
status = gdpicturePDF.GetSignatureProperties(0, sigName, sigReason, sigLocation, sigInfo, sigDate,
stampLeft, stampTop, stampWidth, stampHeight, stampPage,
docValid, certValid, certFriendName, certIssuer, certNotBefore, certNotAfter, certSubject, certVersion, sigTime, sigLevel)
If status = GdPictureStatus.OK Then
Dim message As String = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString()
If (stampWidth = 0) OrElse (stampHeight = 0) Then
message = message + ", the signature is invisible,"
Else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString()
End If
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:" + vbCrLf
If docValid Then
message = message + "The document has not been changed after signing." + vbCrLf
Else
message = message + "The document has been changed after signing." + vbCrLf
End If
If certValid Then
message = message + "The signature is valid." + vbCrLf
Else
message = message + "The signature is not valid." + vbCrLf
End If
message = message + "Signature Info:" + vbCrLf + " Name: " + sigName + vbCrLf + " Reason: " + sigReason + vbCrLf + " Location: " + sigLocation + vbCrLf + " Contact info: " + sigInfo + vbCrLf + " Date: " + sigDate + vbCrLf +
"Certificate Info:" + vbCrLf + " Name: " + certFriendName + vbCrLf + " Issuer: " + certIssuer + vbCrLf + " Subject: " + certSubject + vbCrLf + " Version: " + certVersion + vbCrLf + " Time: " + sigTime.ToString() + vbCrLf +
"Certificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + "."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption)
End If
Else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "GetSignatureProperties";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_signed.pdf", false);
if (status == GdPictureStatus.OK)
{
int signatureCount = gdpicturePDF.GetSignatureCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (signatureCount > 0)
{
string sigName = "", sigReason = "", sigLocation = "", sigInfo = "", sigDate = "", certFriendName = "", certIssuer = "", certSubject = "";
float stampLeft = 0, stampTop = 0, stampWidth = 0, stampHeight = 0;
int stampPage = 0, certVersion = 0;
bool docValid = false, certValid = false;
DateTime certNotBefore = new DateTime(), certNotAfter = new DateTime(), sigTime = new DateTime();
PdfSignatureCertificationLevel sigLevel = PdfSignatureCertificationLevel.NotCertified;
status = gdpicturePDF.GetSignatureProperties(0, ref sigName, ref sigReason, ref sigLocation, ref sigInfo, ref sigDate,
ref stampLeft, ref stampTop, ref stampWidth, ref stampHeight, ref stampPage,
ref docValid, ref certValid, ref certFriendName, ref certIssuer,
ref certNotBefore, ref certNotAfter, ref certSubject, ref certVersion, ref sigTime, ref sigLevel);
if (status == GdPictureStatus.OK)
{
string message = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString();
if ((stampWidth == 0) || (stampHeight == 0))
message = message + ", the signature is invisible,";
else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString();
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:\n";
if (docValid)
message = message + "The document has not been changed after signing.\n";
else
message = message + "The document has been changed after signing.\n";
if (certValid)
message = message + "The signature is valid.\n";
else
message = message + "The signature is not valid.\n";
message = message + "Signature Info:\n Name: " + sigName + "\n Reason: " + sigReason + "\n Location: " + sigLocation + "\n Contact info: " + sigInfo + "\n Date: " + sigDate +
"\nCertificate Info:\n Name: " + certFriendName + "\n Issuer: " + certIssuer + "\n Subject: " + certSubject + "\n Version: " + certVersion + "\n Time: " + sigTime.ToString() +
"\nCertificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + ".";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption);
}
else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also