Rank: Newbie Groups: Member
Joined: 1/7/2019 Posts: 2
|
Hi, is there any way in EO to check if a pdf is password protected or read only?
I want to edit a pdf but first I want to check check if it is password protected.
Thanks!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,258
|
Hi,
You can just try to open the PDF file with new PdfDocument(file_name) and if it throws an exception with "invalid password" message, then the file is password protected.
Note that for PDF file, it's possible that the file is not password protected but is marked as "secure". In this case you can load the file without any password, but PdfDocument.Security.OwnerPasswordProvided will be true. However the PDF specification states that you should not honor the permission settings on the file (exposed to you through PdfDocument.Security.Permissions), however there is nothing technical that prevents you from modifying the file in this case.
Thanks!
|