Hi:
This is how I set the security properties in a pdf file:
using (var documenttosecure = new Aspose.Pdf.Document(inputFilePath))
{
using (var pdfOutput = newPdfFileSecurity(documenttosecure))
{
var docP = DocumentPrivilege.AllowAll;
docP.AllowPrint = true;
docP.AllowCopy = true;
docP.AllowModifyContents = false;
pdfOutput.SetPrivilege(docP);
documenttosecure.Save(outputFile);
}
}
But then I need to load again the same pdf file and I need to access the DocumentPrivilege from the pdf document to know if the property “AllowmodifyContents” is false or true.
This is how I load the pdf file:
public static bool HasPdfFileAnyTypeOfPasswordProtection(string inputFilePath)
{
const int acSecurityLevelPermissions = 3900;
try
{
var pdfFileInfo = new PdfFileInfo(inputFilePath);
//Find if pdf file has security to open
if (pdfFileInfo.HasOpenPassword)
{
return true;
}
//Find if the pdf document has security to edit
if (pdfFileInfo.HasEditPassword)
{
return true;
}
return false;
}
catch (Exception exception)
{
Logger.Error(exception, $"Could not open the file {inputFilePath}. Probably because is password protected.");
throw;
}
}
Can you help me to find the “AllowModifyContents” property?
Regards;
Rikard