from ironpdf import * # Open an Encrypted File, alternatively create a new PDF from Html pdf = PdfDocument.FromFile("encrypted.pdf", "password") # Edit file metadata pdf.MetaData.Author = "Satoshi Nakamoto" pdf.MetaData.Keywords = "SEO, Friendly" pdf.MetaData.ModifiedDate = Now() # The following code makes a PDF read only and will disallow copy & paste and printing pdf.SecuritySettings.RemovePasswordsAndEncryption() pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key") pdf.SecuritySettings.AllowUserAnnotations = False pdf.SecuritySettings.AllowUserCopyPasteContent = False pdf.SecuritySettings.AllowUserFormData = False pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights # Change or set the document encryption password pdf.SecuritySettings.OwnerPassword = "top-secret" # password to edit the pdf pdf.SecuritySettings.UserPassword = "sharable" # password to open the pdf pdf.SaveAs("secured.pdf")