How can we get or set Document restrications summery in security tab

Hi Team,

Could you please give the code to set and get the details in Document restrictions summery details.
PFA.

Thanks,
Harish.Screenshot (13).png (133.3 KB)

@HarishGali

You can please check code snippet to set privileges in PDF documents in the below documentation articles:

Could you please help me with the code to get allready existed values.

I need to check first either true or false, then set it.

Could you please provide the code to get the already existed properties.

Thanks,
Harish

@HarishGali

Please try to use the code snippet like below:

// C# Code
Facades.PdfFileInfo fileInfo = new Facades.PdfFileInfo(new Document("input.pdf"));
fileInfo.GetPdfVersion();
Facades.DocumentPrivilege dp = fileInfo.GetDocumentPrivilege();
var allowcopy = dp.AllowCopy;

Hi ali,

after setting properties, when opining pdf document (Secured) was showing after the name of document.

PFAJOB1903_Output_bluetext3.pdf (77.4 KB)

Could you please tell me how to overcome. or any other way to set documentprivilege otherthen pdfsecurity.

also, help me with the code to allow page extraction.

Thanks,
Harish

@HarishGali

It is the behavior of Adobe Reader and we are not sure whether it can be changed or not. Hence, an investigation ticket as PDFNET-52011 has been logged in our issue tracking system to analyze this requirement. We will look into detail of the ticket and let you know as soon as the ticket is resolved. Please spare us some time.

You can set ChangeAllowLevel Property to “4” in order to disable Page Extraction.

Aspose.Pdf.Facades.DocumentPrivilege privilege = info.GetDocumentPrivilege();
privilege.ChangeAllowLevel = 4; 

Aspose.Pdf.Facades.DocumentPrivilege privilege = info.GetDocumentPrivilege();
privilege.ChangeAllowLevel = 4;

after doing, how to save the changes to document, please help me with code to save the changes to pdf.

@HarishGali

Please check the below complete sample code:

Facades.PdfFileInfo info = new Facades.PdfFileInfo();
info.BindPdf(pdf);
Aspose.Pdf.Facades.DocumentPrivilege privilege = info.GetDocumentPrivilege();
privilege.ChangeAllowLevel = 4;

Aspose.Pdf.Facades.PdfFileSecurity fs = new Aspose.Pdf.Facades.PdfFileSecurity();
fs.BindPdf(pdf);
fs.SetPrivilege(privilege);
fs.Save(dataDir + "changed.pdf");