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")
#Open an Encrypted File, alternatively create a new PDF from Html
#Edit file metadata
#The following code makes a PDF read only and will disallow copy And paste and printing
#Change or set the document encryption password
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'from ironpdf import * pdf = PdfDocument.FromFile("encrypted.pdf", "password") pdf.MetaData.Author = "Satoshi Nakamoto" pdf.MetaData.Keywords = "SEO, Friendly" pdf.MetaData.ModifiedDate = Now() 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 pdf.SecuritySettings.OwnerPassword = "top-secret" # password @to edit the pdf pdf.SecuritySettings.UserPassword = "sharable" # password @to open the pdf pdf.SaveAs("secured.pdf")