Dim caption As String = "Example: GetEncryptionScheme"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("encrypted.pdf", False)
If status = GdPictureStatus.OK Then
Dim encryption As PdfEncryption = PdfEncryption.PdfEncryptionUnknown
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If encrypted Then
'This is incorrect usage.
encryption = gdpicturePDF.GetEncryptionScheme()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is encrypted, the encryption scheme is: " + encryption.ToString() + vbCrLf + "Please use SetPassword to decrypt your document.", caption)
End If
'You need to provide the correct password here.
status = gdpicturePDF.SetPassword("user")
If status = GdPictureStatus.OK Then
'The correct usage.
encryption = gdpicturePDF.GetEncryptionScheme() ' correct use
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is decrypted, the encryption scheme is: " + encryption.ToString(), caption)
End If
Else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption)
End If
Else
encryption = gdpicturePDF.GetEncryptionScheme()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The PDF document is not encrypted, the encryption scheme is: " + encryption.ToString(), caption)
End If
End If
Else
MessageBox.Show("The IsEncrypted() 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 = "Example: GetEncryptionScheme";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example in the SetPassword method for creating this file.
GdPictureStatus status = gdpicturePDF.LoadFromFile("encrypted.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfEncryption encryption = PdfEncryption.PdfEncryptionUnknown;
bool encrypted = gdpicturePDF.IsEncrypted();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (encrypted)
{
//This is incorrect usage.
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("This PDF document is encrypted, the encryption scheme is: " + encryption.ToString() + "\nPlease use SetPassword to decrypt your document.", caption);
//You need to provide the correct password here.
status = gdpicturePDF.SetPassword("user");
if (status == GdPictureStatus.OK)
{
//The correct usage.
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("This PDF document is decrypted, the encryption scheme is: " + encryption.ToString(), caption);
}
else
{
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The PDF document is not encrypted, the encryption scheme is: " + encryption.ToString(), caption);
}
}
else
{
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();