I am using Aspose library to read, open and save pdf file. I am looking the way to get the security value of a pdf file from the property "AllowModifyContents".
This is how it is set:
using (var documenttosecure = new Aspose.Pdf.Document(inputFilePath))
{
using (var pdfOutput = new PdfFileSecurity(documenttosecure))
{
var docP = DocumentPrivilege.AllowAll;
docP.AllowPrint = true;
docP.AllowCopy = true;
docP.AllowModifyContents = false;
pdfOutput.SetPrivilege(docP);
documenttosecure.Save(outputFile);
}
}
Now I need to get that pdf and find the property AllowModifyContents from the pdf DocumentPrivilege.
Do you know how to read that property value?
Thanks for your help; Sergio
GetDocumentPrivilege()
method of Aspose.Pdf.Facades.PdfFileInfo
class, returns an object of type DocumentPrivilege
, through which you can determine the value of AllowModifyContents
property. Please check following code snippet, in order to achieve your requirement.
// Instantiate PdfFileInfo Class object.
Aspose.Pdf.Facades.PdfFileInfo info = new Aspose.Pdf.Facades.PdfFileInfo();
// Load your encrypted PDF document.
info.BindPdf(dataDir + "EncryptedDocument.pdf");
// Get DocumentPrivilege
Facades.DocumentPrivilege documentPrivilege = info.GetDocumentPrivilege();
// Determine AllowModifyContents
bool AllowModifyContents = documentPrivilege.AllowModifyContents;
Note: I am Asad Ali and work as Developer Evangelist at Aspose.