// PM> Install-Package IronPdf
using IronPdf;
//Open an Encrypted File, alternatively create a new PDF from Html
using PdfDocument Pdf = PdfDocument.FromFile("encrypted.pdf", "password");
//Edit file metadata
Pdf.MetaData.Author = "Satoshi Nakamoto";
Pdf.MetaData.Keywords = "SEO, Friendly";
Pdf.MetaData.ModifiedDate = DateTime.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 = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// change or set the document encrpytion password
Pdf.Password = "my-password";
Pdf.SaveAs("secured.pdf");
' PM> Install-Package IronPdf
Imports IronPdf
'Open an Encrypted File, alternatively create a new PDF from Html
Private PdfDocument As using
'Edit file metadata
Pdf.MetaData.Author = "Satoshi Nakamoto"
Pdf.MetaData.Keywords = "SEO, Friendly"
Pdf.MetaData.ModifiedDate = DateTime.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 = IronPdf.Security.PdfPrintSecurity.FullPrintRights
' change or set the document encrpytion password
Pdf.Password = "my-password"
Pdf.SaveAs("secured.pdf")