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() # Edit file security settings # 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.Password = "my-password" pdf.SaveAs("secured.pdf")
PDF加密与解密