PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
Compatibility with PDF reader applications https://forum.pdfsharp.net/viewtopic.php?f=2&t=4873 |
Page 1 of 1 |
Author: | lanselof@gmail.com [ Thu Aug 28, 2025 6:46 pm ] |
Post subject: | Compatibility with PDF reader applications |
Using: C# .NET 8.0 WinForms project / PDFSharp v6.2.0 We are opening an existing PDF file that was generated by MS-Word, adding permissions and a password and then saving it again. It works for most users and it correctly opens the PDF document without prompting for a password. However for some users, it asks for a password when trying to open the document. I guess that they are using non standard PDF reader applications. Is there anything we can do to make it compatible for them too? Current code: Code: string ownerKey = Convert.ToBase64String(CryptoHelper.RandomKey());
using (PdfDocument pdf = PdfReader.Open(tempPdfPath, PdfDocumentOpenMode.Modify)) { pdf.SecuritySettings.OwnerPassword = ownerKey; pdf.SecuritySettings.UserPassword = string.Empty; pdf.SecuritySettings.PermitPrint = true; pdf.SecuritySettings.PermitModifyDocument = false; pdf.SecuritySettings.PermitExtractContent = false; pdf.Save(tempPdfPath); } internal static class CryptoHelper { // Return 16 random bytes (128-bit) every call. internal static byte[] RandomKey() { byte[] key = new byte[16]; RandomNumberGenerator rng = RandomNumberGenerator.Create(); rng.GetBytes(key); return key; } } |
Author: | () => true [ Sun Aug 31, 2025 8:35 am ] |
Post subject: | Re: Compatibility with PDF reader applications |
lanselof@gmail.com wrote: Is there anything we can do to make it compatible for them too? Some users reported that the experimental PDF viewer of Edge cannot open some encrypted PDF files. Try an older encryption standard supported by Edge. See also: https://github.com/empira/PDFsharp/issu ... 2847879920 https://stackoverflow.com/questions/797 ... ge-137-138 |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |