ComponentOne PDF for WPF and Silverlight
Creating and Writing Encrypted Files
PDF for WPF and Silverlight Overview > Task-Based Help > Creating and Writing Encrypted Files

To create and write an encrypted Pdf file using owner and user passwords you can first use the LoadDocument method with password parameter and then create and write the encrypted file. For more information on how to use the LoadDocument method seeLoading Documents from the Web.

Visual Basic
Copy Code
 Using stream = dlg.OpenFile()
    Dim pdf = New C1PdfDocument()
       pdf.Security.OwnerPassword = "ownerPassword"
       pdf.Security.UserPassword = "userPassword"
    ' added others content of the pdf file
       pdf.Save(stream)
End Using
C#
Copy Code
using (var stream = dlg.OpenFile())
                {
                    var pdf = new C1PdfDocument();
                    pdf.Security.OwnerPassword = "ownerPassword";
                    pdf.Security.UserPassword = "userPassword";

                     …      // added others content of the pdf file

                    pdf.Save(stream);
         }