PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Pdf become password protected after setting owner password
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4409
Page 1 of 1

Author:  ivans [ Wed Jan 04, 2023 2:31 pm ]
Post subject:  Pdf become password protected after setting owner password

Using pdfsharp version PDFsharp 1.51.5185-gdi

After setting owner password pdf become password protected. If original pdf is first converted to pdf1.4 using itext, then setting owner password works.

It looks like original pdf must be somehow corrupt. How, how to detect that?

Code:
Code:
using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
   var document = PdfReader.Open(file);
   document.SecuritySettings.OwnerPassword = "aaaaaaaa";

   var ms = new MemoryStream();
   document.Save(ms, false);
   ms.Flush();
   ms.Position = 0;

   using (FileStream output = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
   {
      StreamUtility.CopyStream(ms, output, 32768);
   }
}

Author:  ivans [ Mon Jan 09, 2023 10:00 am ]
Post subject:  Re: Pdf become password protected after setting owner passwo

Nevermind, we found a fix.

Author:  TH-Soft [ Mon Jan 09, 2023 11:39 am ]
Post subject:  Re: Pdf become password protected after setting owner passwo

ivans wrote:
It looks like original pdf must be somehow corrupt.
Not much we can do without the PDF that allows to replicate the issue.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/