Dim caption As String = "Example: IsOwnerPassword"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) = GdPictureStatus.OK Then
Dim PassOk As Boolean = False
Dim isEncrypted As Boolean = gdpicturePDF.IsEncrypted()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isEncrypted Then
If gdpicturePDF.SetPassword("") = GdPictureStatus.OK Then
PassOk = True
Else
'Try this call also with the "owner" password.
If gdpicturePDF.SetPassword("user") = GdPictureStatus.OK Then
PassOk = True
If PassOk = True Then
Dim isOwner As Boolean = gdpicturePDF.IsOwnerPassword()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isOwner Then
MessageBox.Show("The password you have provided is the owner password.", caption)
Else
MessageBox.Show("The password you have provided is the user password.", caption)
End If
End If
End If
End If
End If
If PassOk = False Then
MessageBox.Show("You have provided a wrong password.", caption)
End If
Else
MessageBox.Show("This PDF is not encrypted.", caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsOwnerPassword";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example in the SetPassword method for creating this file.
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) == GdPictureStatus.OK)
{
bool PassOk = false;
bool isEncrypted = gdpicturePDF.IsEncrypted();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isEncrypted)
{
if (gdpicturePDF.SetPassword("") == GdPictureStatus.OK)
{
PassOk = true;
}
else
{
//Try this call also with the "owner" password.
if (gdpicturePDF.SetPassword("user") == GdPictureStatus.OK)
{
PassOk = true;
if (PassOk == true)
{
bool isOwner = gdpicturePDF.IsOwnerPassword();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isOwner)
{
MessageBox.Show("The password you have provided is the owner password.", caption);
}
else
{
MessageBox.Show("The password you have provided is the user password.", caption);
}
}
}
}
}
if (PassOk == false)
{
MessageBox.Show("You have provided a wrong password.", caption);
}
}
else
{
MessageBox.Show("This PDF is not encrypted.", caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();