ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.04k stars 231 forks source link

Pdf Document Metadata and Properties are incorrect when adding UserPassword or OwnerPassword #418

Open dssmith opened 6 months ago

dssmith commented 6 months ago
using PdfSharpCore.Pdf;
using PdfSharpCore.Pdf.Security;

Console.WriteLine("Hello, World!");

var doc = new PdfDocument();
doc.Info.Title = "Issue Submission";
doc.Info.Subject = "Subject";
doc.Info.Author = "Author";
doc.Info.Creator = "Creator";
doc.Info.Keywords = "Keyword:one;Keyword:two";
doc.Info.ModificationDate = DateTime.Now;

doc.SecuritySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted128Bit;
doc.SecuritySettings.UserPassword = "user";
doc.SecuritySettings.OwnerPassword = "owner";

PdfPage page = doc.AddPage();

doc.Save(@"c:\temp\test.pdf");

image

`