Hi,
I have a pdf with a Owner password and I don't know it because is from one my clients to enter in the system. Normaly I can read the PDF with Acrobat but in read only mode. I use the new class of DynamicPDF "EncryptionInfo" to know if the pdf have a password. But my question : He have a way to just open the pdf and read without having the password or not?
Thanks
Owner password protected
Re: Owner password protected
Support · Aug 27, 2020Hello,
There are two types of passwords that one can set in a PDF:
1. User Password – If this is set you will need to provide the password when viewing the PDF.
2. Owner Password – If this is set you will need to provide the password for editing and/or merging the PDF.
It is possible that your PDF only has an owner password was and not a user password. Hence you are able to open and view the PDF but not able to modify or merge it without the owner password.
If the PDF is encrypted with an owner password then you will need to load the PDF using the PdfDocument class constructor which takes file path/byte array and owner password as arguments. Then append or merge it with MergeDocument object. Below is the code sample for it.
Please note that it is not possible to merge the password protected PDFs without specifying the correct owner password.
PdfDocument pdfDoc = new PdfDocument(@"Secured PDF file path", "correct owner password");
MergeDocument document = new MergeDocument( );
document.Append(pdfDoc);
document.Draw(@"C:\temp\MyOutput.pdf");
Also below is the code sample to check whether the PDF is protected with owner or user password.
EncryptionInfo info = PdfDocument.GetEncryptionInfo("PDF file path or byte array");
bool hasOwnerPasword = info.HasOwnerPassword;
bool hasUserPassword = info.HasUserPassword;
Thanks,
ceTe Software Support Team