Dim caption As String = "Example: GetRight"
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 encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'Setting the user password.
status = gdpicturePDF.SetPassword("user")
'Try the same with providing the owner password.
'status = gdpicturePDF.SetPassword("owner");
If status = GdPictureStatus.OK Then
encrypted = gdpicturePDF.IsEncrypted()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso Not encrypted Then
Dim encryptScheme As PdfEncryption = gdpicturePDF.GetEncryptionScheme()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim permList As String = ""
If gdpicturePDF.GetRight(PdfRight.PdfRightCanView) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanView.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanPrint) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanPrint.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanModify) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanModify.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanCopy) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanCopy.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanAddNotes) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanAddNotes.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanFillFields) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanFillFields.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanCopyAccess) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanCopyAccess.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanAssemble) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanAssemble.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanPrintFull) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanPrintFull.ToString() + vbCrLf
End If
MessageBox.Show("PDF encryption is " + encryptScheme.ToString() + "." + vbCrLf + "Access permissions are: " + vbCrLf + permList.ToString(), caption)
Else
MessageBox.Show("The GetEncryptionScheme() method has failed with the status: " + status.ToString())
End If
End If
Else
MessageBox.Show("You have probably provided a bad password.", caption)
End If
Else
MessageBox.Show("The file is unencrypted.", caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetRight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("encrypted.pdf", false);
//Please see the example in the SetPassword method for creating this file.
if (status == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
{
//Setting the user password.
status = gdpicturePDF.SetPassword("user");
//Try the same with providing the owner password.
//status = gdpicturePDF.SetPassword("owner");
if (status == GdPictureStatus.OK)
{
encrypted = gdpicturePDF.IsEncrypted();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && !encrypted)
{
PdfEncryption encryptScheme = gdpicturePDF.GetEncryptionScheme();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string permList = "";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanView) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanView.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanPrint) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanPrint.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanModify) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanModify.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanCopy) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanCopy.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanAddNotes) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanAddNotes.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanFillFields) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanFillFields.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanCopyAccess) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanCopyAccess.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanAssemble) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanAssemble.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanPrintFull) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanPrintFull.ToString() + "\n";
MessageBox.Show("PDF encryption is " + encryptScheme.ToString() + ".\nAccess permissions are: \n" + permList.ToString(), caption);
}
else
{
MessageBox.Show("The GetEncryptionScheme() method has failed with the status: " + status.ToString());
}
}
}
else
{
MessageBox.Show("You have probably provided a bad password.", caption);
}
}
else
{
MessageBox.Show("The file is unencrypted.", caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();