title: Opening a Password Protected PDF Using PDFsharp
body: <p>In my program I write away PDFs with a password I specify. This is important as I know the password to the PDFs I'm trying to open (not hacking it or anything). I password protect the PDF like so;</p>
  
  <pre><code>Application.Current.Dispatcher.InvokeAsync(new Action(() =&gt;
  {
      string sourcePath = sourceFilePath;
      string targetPath = @"C:\ExamplePath";
  
      useReturnedOHPath = true;
  
      string sourceFile = Path.Combine(sourcePath, fileName);
  
      var document = PdfReader.Open(sourceFile);
      var securitySettings = document.SecuritySettings;
      securitySettings.UserPassword = "ExamplePass";
  
      securitySettings.PermitAccessibilityExtractContent = false;
      securitySettings.PermitAnnotations = false;
      securitySettings.PermitAssembleDocument = false;
      securitySettings.PermitExtractContent = false;
      securitySettings.PermitFormsFill = true;
      securitySettings.PermitFullQualityPrint = false;
      securitySettings.PermitModifyDocument = true;
      securitySettings.PermitPrint = false;
  
      document.Save(sourceFile);
      MessageBox.Show(sourceFile);
  
      string cleanPath = CleanFileName(selectedPerson.ID + " " + DateTime.Now.ToString("dd-MM-yyyy hh-mm-ss") + ".pdf");
      ohDestFile = Path.Combine(targetPath, cleanPath);
  
      File.Copy(sourceFile, ohDestFile, true);
  }), DispatcherPriority.ContextIdle);
  </code></pre>
  
  <p>Because of this I know that the password to the PDF is <code>ExamplePass</code>. Now when I come to open the PDF from within my program I have tried a few methods, simply;</p>
  
  <pre><code>if (selectedOHRecord.Path != string.Empty)
  {
       Process.Start(selectedOHRecord.Path);
  }
  </code></pre>
  
  <p>However understandably this just opens Acrobat and asks for a password. I've also tried adding in:</p>
  
  <pre><code>PdfDocument document = PdfReader.Open(selectedOHRecord.Path, "ExamplePass");
  </code></pre>
  
  <p>Which is taken from the PDFsharp website itself, however when I call this nothing happens at all. Is there a way I can open a PDF and input the password for the user so they don't have to type it?</p>