PdfSharpCore
PdfSharpCore copied to clipboard
Open a pdf file in readonly mode with UserPassword
I am trying to open/read a PDF file with some encryption features.
- Userpassword is not set, I can read this PDF bei opening Adobe Reader etc.
- OwnerPassword is set, I cannot change anything in this PDF. The ownerPassword is unknown.
Is it "by design" impossible to read this PDF to copy pages to another or is it a limitation if PdfSharpCore?
From the PdfReference, Chapter 7.6.3.1:
Once the document has been opened and decrypted successfully, a conforming reader technically has access to the entire contents of the document. There is nothing inherent in PDF encryption that enforces the document permissions specified in the encryption dictionary. Conforming readers shall respect the intent of the document creator by restricting user access to an encrypted PDF file according to the permissions contained in the file.
I do not know whether PdfSharp respects the access-permissions specified in the file, but technically there is nothing stopping you from importing pages from an encrypted document into a new one once you can decrypt the original document.
It boils down to this:
- if the document is protected by a user-password, you have to specify it when opening the document, otherwise you will not be able to decrypt it
- if the document is protected by an owner-password, you should be able to read the document using the default user-password (check out the mentioned chapter from the PdfReference)