GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / SetCertificate Method / SetCertificate(String,String) Method
The file path to the digital ID file. This file contains the certificate given to decrypt the currently loaded PDF document.
The password to open the digital ID file specified above.
Example





In This Topic
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
'Declaration
 
Public Overloads Function SetCertificate( _
   ByVal CertPath As String, _
   ByVal PFXPassword As String _
) As GdPictureStatus
public GdPictureStatus SetCertificate( 
   string CertPath,
   string PFXPassword
)
public function SetCertificate( 
    CertPath: String;
    PFXPassword: String
): GdPictureStatus; 
public function SetCertificate( 
   CertPath : String,
   PFXPassword : String
) : GdPictureStatus;
public: GdPictureStatus SetCertificate( 
   string* CertPath,
   string* PFXPassword
) 
public:
GdPictureStatus SetCertificate( 
   String^ CertPath,
   String^ PFXPassword
) 

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.

Remarks
The public key security handler applies the authentication with a pair of a public key (a certificate) and a private key. In comparison to the standard security handler, this allows you to define individual rights and unique access permissions for different recipients. Only specified recipients will be able to open the encrypted PDF document.
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