SetCertificate(String,String) Method
In This Topic
Sets the certificate (the associated public key), contained in the digital ID stored in the specified external PKCS#12 file with the filename extension ".p12" or ".pfx". The method works with the file specified by its file path as a string.
This method applies the concept of the public key security. It is assumed, that the currently loaded PDF document is encrypted using the provided digital ID. The document is subsequently decrypted using the associated public key.
Syntax
Parameters
- CertPath
- The file path to the digital ID file. This file contains the certificate given to decrypt the currently loaded PDF document.
- PFXPassword
- The password to open the digital ID file specified above.
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 set a certificate from a file to decrypt the document.
Dim caption As String = "SetCertificate"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", False) = GdPictureStatus.OK Then
'Specify your digitalID filename here.
Dim digitalID_filename As String = "your_digitalID_filename.pfx"
'Specify the corresponding password here.
Dim password As String = "password"
Dim status As GdPictureStatus = gdpicturePDF.SetCertificate(digitalID_filename, password)
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(), caption)
'You can do your stuff with the PDF document here.
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "SetCertificate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", false) == GdPictureStatus.OK)
{
//Specify your digitalID filename here.
string digitalID_filename = "your_digitalID_filename.pfx";
//Specify the corresponding password here.
string password = "password";
GdPictureStatus status = gdpicturePDF.SetCertificate(digitalID_filename, password);
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(),caption);
//You can do your stuff with the PDF document here.
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Example
How to set a certificate from a file to decrypt the document.
Dim caption As String = "SetCertificate"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", False) = GdPictureStatus.OK Then
'Specify your digitalID filename here.
Dim digitalID_filename As String = "your_digitalID_filename.pfx"
'Specify the corresponding password here.
Dim password As String = "password"
Dim status As GdPictureStatus = gdpicturePDF.SetCertificate(digitalID_filename, password)
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(), caption)
'You can do your stuff with the PDF document here.
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "SetCertificate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", false) == GdPictureStatus.OK)
{
//Specify your digitalID filename here.
string digitalID_filename = "your_digitalID_filename.pfx";
//Specify the corresponding password here.
string password = "password";
GdPictureStatus status = gdpicturePDF.SetCertificate(digitalID_filename, password);
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(),caption);
//You can do your stuff with the PDF document here.
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also