Hello,
I’m using this article How to Remove All Restrictions from PDF in C# to remove all restrictions but it’s not doing nothing.
The actual code I’m using is :
public void MssRemoveSecuritySettings(byte[] ssLicense, byte[] ssFile, string ssPassword, out bool ssResult, out string ssResultMessage, out byte[] ssOutFile) {
ssOutFile = new byte[] { };
ssResult = false;
ssResultMessage = "";
try
{
setPdfLicense(ssLicense);
MemoryStream inStream = new MemoryStream(ssFile);
// Create PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(inStream);
// empty password?
if (!string.IsNullOrEmpty(ssPassword))
{
// decrypt if we have password
fileSecurity.DecryptFile(ssPassword);
}
// Create DocumentPrivileges object
var privilege = DocumentPrivilege.AllowAll;
// Set Privilege
fileSecurity.SetPrivilege(privilege);
MemoryStream OutStream = new MemoryStream();
fileSecurity.Save(OutStream);
ssOutFile = OutStream.ToArray();
ssResult = true;
ssResultMessage = "Success";
}
catch (Exception e)
{
ssResult = false;
ssResultMessage = e.Message;
}
}
The output file has the same restrictions as the input file.
Our example file has :
Security Method : Password Security
Document Assembly : Not Allowed
age Extraction : Not Allowed
And we wanted to allow both.