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);
}
}