using IronPdf;
// Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Get file metadata
System.Collections.Generic.List<string> metadatakeys = pdf.MetaData.Keys(); // returns {"Title", "Creator", ...}
// Remove file metadata
pdf.MetaData.RemoveMetaDataKey("Title");
metadatakeys = pdf.MetaData.Keys(); // return {"Creator", ...} // title was deleted
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = System.DateTime.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 = IronPdf.Security.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");
Imports System
Imports IronPdf
' Open an Encrypted File, alternatively create a new PDF from Html
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")
' Get file metadata
Private metadatakeys As System.Collections.Generic.List(Of String) = pdf.MetaData.Keys() ' returns {"Title", "Creator", ...}
' Remove file metadata
pdf.MetaData.RemoveMetaDataKey("Title")
metadatakeys = pdf.MetaData.Keys() ' return {"Creator", ...} // title was deleted
' Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.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 = IronPdf.Security.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")
Install-Package IronPdf
Mots de passe, sécurité et métadonnées
Des métadonnées granulaires et des paramètres de sécurité peuvent être appliqués. Il est désormais possible d'interdire l'impression, la lecture seule et le cryptage des documents PDF. le cryptage 128 bits, le décryptage et la protection par mot de passe des documents PDF sont pris en charge.
Liens vers des documents connexes
Prêt à commencer ? Version : 2024.9 vient de paraître