Page 1 of 1
Programmatically determine whether the PDF is secured?
Posted: Wed Apr 25, 2018 6:05 pm
by Shaun Luttin
How can we programmatically determine whether the PDF is secured?
We're looking for something like this:
Code: Select all
private bool IsDocumentSecured(int docId)
{
_viewer.GetDocumentProperty(docId, "Document.Security", out var isSecured);
return (int) isSecured == 1;
}
Re: Programmatically determine whether the PDF is secured?
Posted: Thu Apr 26, 2018 11:30 am
by Tracker Supp-Stefan
Hello Shaun,
I believe in the Viewer this was the way:
https://help.pdf-xchange.com/DEV/d ... iongranted
Regards,
Stefan
Re: Programmatically determine whether the PDF is secured? SOLVED
Posted: Wed May 02, 2018 12:55 am
by Shaun Luttin
We ended up doing it like this:
Code: Select all
public bool IsDocumentSecured(int docId) {
// For now we assume the document is secured if the Delete Page operation is not granted.
// We asked a forum question here that might surface a better approach.
// https://forum.pdf-xchange.com/viewtopic.php?f=36&t=30839&p=123742#p123742
return !IsOperationGranted(docId, ObjectIdentifier.Page, OperationIdentifier.Delete);
}
public bool IsOperationGranted(int documentId, ObjectIdentifier objectId, OperationIdentifier operationId) {
var dataIn = new object[] {
(int) objectId,
(int) operationId
};
_viewer.DoDocumentVerb(documentId, null, "IsOperationGranted", dataIn, out var isGranted);
return (int) isGranted == 1;
}
Re: Programmatically determine whether the PDF is secured?
Posted: Wed May 02, 2018 11:19 am
by Tracker Supp-Stefan
Lovely Shaun Luttin,
Thanks for sharing your solution!
Regards,
Stefan