Dim caption As String = "Example: IsEncrypted"
Dim gdpicturePDF As New GdPicturePDF()
'We assume the test.pdf is unencrypted PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'This is an incorrect option.
MessageBox.Show("This PDF document is encrypted.", caption)
Else
'This is a correct option.
MessageBox.Show("This PDF document is unencrypted.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed.", caption)
End If
If gdpicturePDF.CloseDocument() <> GdPictureStatus.OK Then
Return
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
'Please see the example in the SetPassword method for creating this file.
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'This is a correct option, you can provide a password here.
MessageBox.Show("This PDF document is encrypted.", caption)
'Providing an user password.
Dim status As GdPictureStatus = gdpicturePDF.SetPassword("user")
If status = GdPictureStatus.OK Then
encrypted = gdpicturePDF.IsEncrypted()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If encrypted Then
'This is an incorrect option.
MessageBox.Show("This PDF document is still encrypted.", caption)
Else
'This is a correct option.
MessageBox.Show("This PDF document is decrypted now.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption)
End If
Else
'This is an incorrect option.
MessageBox.Show("This PDF is unencrypted.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsEncrypted";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//We assume the test.pdf is unencrypted PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
//This is an incorrect option.
MessageBox.Show("This PDF document is encrypted.", caption);
else
//This is a correct option.
MessageBox.Show("This PDF document is unencrypted.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed.", caption);
if (gdpicturePDF.CloseDocument() != GdPictureStatus.OK) return;
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
//Please see the example in the SetPassword method for creating this file.
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
{
//This is a correct option, you can provide a password here.
MessageBox.Show("This PDF document is encrypted.", caption);
//Providing an user password.
GdPictureStatus status = gdpicturePDF.SetPassword("user");
if (status == GdPictureStatus.OK)
{
encrypted = gdpicturePDF.IsEncrypted();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (encrypted)
//This is an incorrect option.
MessageBox.Show("This PDF document is still encrypted.", caption);
else
//This is a correct option.
MessageBox.Show("This PDF document is decrypted now.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption);
}
else
//This is an incorrect option.
MessageBox.Show("This PDF is unencrypted.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed.", caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();