Difference between OwnerPassword and UserPassword

Get technical support of PDF Metamorphosis .Net in C# and VB.Net
stacieweber99
Posts: 2
Joined: Thu Jul 15, 2021 10:11 pm
Contact:

Difference between OwnerPassword and UserPassword

Post by stacieweber99 »

Hello,

What is the difference between p.PdfSettings.PdfSecurity.OwnerPassword and p.PdfSettings.PdfSecurity.UserPassword ?

I have seen that OwnerPassword does not always password protect PDF's.
When I switched to using the UserPassword property, the password protection began to work as expected.

I was wondering why there are two properties and the difference?

Thank you.
Oliver
Posts: 28
Joined: Wed Aug 19, 2020 11:59 am
Contact:

Re: Difference between OwnerPassword and UserPassword

Post by Oliver »

Hello.

I'll try to explain what is the difference.

PDF Metamorphosis .Net and p.PdfSettings.PdfSecurity.UserPassword = "0987654321";

The user password will be required to open an encrypted PDF document for viewing.
The permissions specified in SautinSoft.Document.PdfEncryptionDetails.Permissions will be enforced by the reader software.
The user password can be null or empty string, in this case no password will be required from the user when opening the PDF document. The user password cannot be the same as the owner password.

For example, if you open PDF file in an Viewer and insert the password - "0987654321", you will see, that you may READ only of this PDF file because you are the user of this file:
Document Properties -> Security -> Document Restrictions Summary -> Not Allowed.

Image

PDF Metamorphosis .Net and p.PdfSettings.PdfSecurity.OwnerPassword = "1234567890";

The owner password allows the user to open an encrypted PDF document without any access restrictions specified in SautinSoft.Document.PdfEncryptionDetails.Permissions.
The owner password cannot be the same as the user password. If you don't specify an owner password, then the system will generate a random password when generating the PDF document.

For example, if you open PDF file in an Viewer and insert the password - "1234567890", you will see, that you may edit, printing this PDF file because you are the owner of this file:
Document Properties -> Security -> Document Restrictions Summary -> Allowed.

Image

Try to play with these settings and you will see the difference:

Code: Select all

using System;
using System.IO;
using System.Collections;

namespace Sample
{
       class Test
    {

        static void Main(string[] args)
        {

            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            p.PdfSettings.PdfSecurity.OwnerPassword = "1234567890";
            p.PdfSettings.PdfSecurity.UserPassword = "0987654321";
            
            if (p != null)
            {
                string rtfPath = @"..\..\example.rtf";
                string pdfPath = Path.ChangeExtension(rtfPath, ".pdf");

                int i = p.RtfToPdfConvertFile(rtfPath, pdfPath);

                if (i != 0)
                {
                    System.Console.WriteLine("An error occurred during converting RTF to PDF!");
                }
                else
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true });
                }
            }
        }
    }
}
Thank you.
Guest

Re: Difference between OwnerPassword and UserPassword

Post by Guest »

Perfect, thank you.


Last bumped by Anonymous on Wed Aug 25, 2021 7:10 am.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests