Owner password protected

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Owner password protected

DynamicPDF CoreSuite for .NET (v10) Forum

 Aug 26 2020 3:20 PM
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
 Aug 27 2020 10:27 AM
Posted by a ceTe Software moderator
Hello,

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

All times are US Eastern Standard time. The time now is 8:21 AM.