PDF-Verschlüsselung & -Entschlüsselung Dieses Codebeispiel demonstriert, wie man Metadaten ändert, die PDF-Datei schreibgeschützt macht, Berechtigungen konfiguriert und das Dokumentverschlüsselungspasswort mit Hilfe der leistungsstarken C# .NET PDF-Bibliothek von IronPDF ändert. Importieren Sie zunächst ein vorhandenes PDF-Dokument mithilfe der Methode "Öffnen". Diese Methode kann genutzt werden, um passwortgeschützte Dokumente zu öffnen, indem das Passwort als zweiter Parameter angegeben wird, wodurch eine robuste Handhabung geschützter Dateien gewährleistet wird. Um neue Metadateninformationen festzulegen, erstellen Sie zunächst ein Wörterbuch und fügen Sie Schlüssel-Wert-Paare für Metadaten wie Autor und Schlüsselwörter hinzu. Nutzen Sie die overrideMetadata -Methode in IronPDF, um die neuen Metadaten effektiv auf das PDF-Dokument anzuwenden. Entfernen Sie anschließend Passwörter und Verschlüsselung mithilfe der von IronPDF bereitgestellten Methode removePasswordsAndEncryption und konfigurieren Sie die PDF-Datei so, dass sie schreibgeschützt ist, indem Sie mit der Methode makePdfDocumentReadOnly ein neues Passwort festlegen. Dadurch wird die Integrität und Sicherheit des Dokuments gewährleistet. Die Berechtigungen für das PDF-Dokument werden über ein Objekt namens "permissions" konfiguriert, das festlegt, ob bestimmte Aktionen wie Anmerkungen, Inhaltsextraktion, Formularausfüllen und Drucken erlaubt oder verboten sind. Übergeben Sie das Berechtigungsobjekt an die Methode setPermission , um die Barrierefreiheitsfunktionen des Dokuments präzise zu steuern. Zum Schluss ändern oder setzen Sie das Dokumentverschlüsselungspasswort auf "mein-passwort" und speichern die geänderte PDF-Datei als "gesichert.pdf". Dies demonstriert die Fähigkeit von IronPDF zur sicheren Dokumentenverwaltung in der Anwendungsentwicklung. // Import the necessary namespace. using IronPdf; class PdfExample { static void Main() { // Open an existing PDF document. If the document is password protected, provide the password. var pdf = IronPdf.PdfDocument.FromFile("existing.pdf", "document-password"); // Initialize a dictionary to store metadata key-value pairs. var newMetadata = new Dictionary<string, string> { { "Author", "New Author" }, { "Keywords", "PDF, Documentation, Example" } }; // Apply the new metadata to the PDF document. pdf.OverrideMetadata(newMetadata); // Remove any existing passwords and encryption. pdf.RemovePasswordsAndEncryption(); // Make the PDF document read-only by setting a read-only password. pdf.MakePdfDocumentReadOnly("read-only-password"); // Define and set the permissions for the PDF document. var permissions = new PdfPermissions { AllowAnnotations = false, AllowContentExtraction = false, AllowFormFilling = true, AllowPrinting = false, AllowDocumentAssembly = false }; pdf.SetPermissions(permissions); // Change the document encryption password. pdf.SaveAs("secured.pdf", "my-password"); // Save the modified PDF with a new security password. } } // Import the necessary namespace. using IronPdf; class PdfExample { static void Main() { // Open an existing PDF document. If the document is password protected, provide the password. var pdf = IronPdf.PdfDocument.FromFile("existing.pdf", "document-password"); // Initialize a dictionary to store metadata key-value pairs. var newMetadata = new Dictionary<string, string> { { "Author", "New Author" }, { "Keywords", "PDF, Documentation, Example" } }; // Apply the new metadata to the PDF document. pdf.OverrideMetadata(newMetadata); // Remove any existing passwords and encryption. pdf.RemovePasswordsAndEncryption(); // Make the PDF document read-only by setting a read-only password. pdf.MakePdfDocumentReadOnly("read-only-password"); // Define and set the permissions for the PDF document. var permissions = new PdfPermissions { AllowAnnotations = false, AllowContentExtraction = false, AllowFormFilling = true, AllowPrinting = false, AllowDocumentAssembly = false }; pdf.SetPermissions(permissions); // Change the document encryption password. pdf.SaveAs("secured.pdf", "my-password"); // Save the modified PDF with a new security password. } } ' Import the necessary namespace. Imports IronPdf Friend Class PdfExample Shared Sub Main() ' Open an existing PDF document. If the document is password protected, provide the password. Dim pdf = IronPdf.PdfDocument.FromFile("existing.pdf", "document-password") ' Initialize a dictionary to store metadata key-value pairs. Dim newMetadata = New Dictionary(Of String, String) From { {"Author", "New Author"}, {"Keywords", "PDF, Documentation, Example"} } ' Apply the new metadata to the PDF document. pdf.OverrideMetadata(newMetadata) ' Remove any existing passwords and encryption. pdf.RemovePasswordsAndEncryption() ' Make the PDF document read-only by setting a read-only password. pdf.MakePdfDocumentReadOnly("read-only-password") ' Define and set the permissions for the PDF document. Dim permissions = New PdfPermissions With { .AllowAnnotations = False, .AllowContentExtraction = False, .AllowFormFilling = True, .AllowPrinting = False, .AllowDocumentAssembly = False } pdf.SetPermissions(permissions) ' Change the document encryption password. pdf.SaveAs("secured.pdf", "my-password") ' Save the modified PDF with a new security password. End Sub End Class $vbLabelText $csharpLabel PDF-Verschlüsselungs- und Entschlüsselungscode-Beispiel ansehen Verwandte Doku-Links Auf Github ansehen Verwandtes Tutorial Verwandte Anleitung Klassendokumentation Sprachpakete herunterladen IronPDF DLL herunterladen Ein Problem auf dieser Seite melden Bereit anzufangen? Version: 2025.11 gerade veröffentlicht Kostenlose npm-Installation Lizenzen anzeigen
In einer Live-Umgebung testen Testen Sie ohne Wasserzeichen in der Produktion.Funktioniert dort, wo Sie es brauchen.
Voll funktionsfähiges Produkt Erhalten Sie 30 Tage voll funktionsfähiges Produkt.In wenigen Minuten einsatzbereit.
24/5 technischer Support Voller Zugriff auf unser Support-Engineering-Team während Ihrer Produktprobe
Alle Ihre Fragen werden beantwortet, um sicherzustellen, dass Sie alle Informationen erhalten, die Sie benötigen. (Völlig unverbindlich.)