PDF Encryption & Decryption
This code example demonstrates how to modify metadata, make the PDF read-only, configure permissions, and change the document encryption password using IronPDF's powerful C# .NET PDF library.
To begin, import an existing PDF document using the open method. This method can be utilized to open password-protected documents by specifying the password as the second parameter, offering robust handling of secured files.
To set new metadata information, start by creating an empty map and add key-value pairs for metadata, such as the author and keywords. Utilize the overrideMetadata
method in IronPDF to apply the new metadata to the PDF document effectively.
Next, remove passwords and encryption using the removePasswordsAndEncryption
method provided by IronPDF, and configure the PDF to be read-only by setting a new password with the makePdfDocumentReadOnly
method, ensuring the document's integrity and security.
Permissions for the PDF document are configured using an object named "permissions," which specifies whether certain actions, such as annotations, content extraction, form filling, and printing, are allowed or disallowed. Pass the permissions object to the setPermission
method to precisely control the document's accessibility features.
Finally, change or set the document encryption password to "my-password," and save the modified PDF as "secured.pdf," showcasing IronPDF’s capability for secure document management in application development.