IronPDF How-Tos Passwords and Permissions How to Set Password and Permissions on a PDF Chaknith Bin Updated:July 28, 2025 Your business is spending too much on yearly subscriptions for PDF security and compliance. Consider IronSecureDoc, which provides solutions for managing SaaS services like digital signing, redaction, encryption, and protection, all for one-time payment. Explore IronSecureDoc Documentation Password protection involves encrypting the document to restrict unauthorized access. It typically includes two types of passwords: the user password (or open password), required to open the document, and the owner password (or permissions password), which controls permissions for editing, printing, and other actions. IronPDF supports everything you need for Password and Permissions for your existing and new PDF files. Granular meta-data and security settings can be applied, this includes the ability to limit PDF documents to be unprintable, read-only, and encrypted; 128-bit encryption, decryption, and password protection are all supported. Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Protect PDF with Password and Permissions in C# Download C# library to protect PDF with password Set OwnerPassword property to prevent PDF file from being edited Set UserPassword property to prevent PDF file from being opened Encrypt PDF file with 128 Bit Encryption Supply the password to FromFile method to open PDF document Set a Password for a PDF We have an example PDF file that we want to protect using IronPDF. Let's execute the following code to add a password to the PDF. In this example, we will use the password password123. :path=/static-assets/pdf/content-code-examples/how-to/pdf-permissions-passwords-add-password.cs using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Secret Information:</h1> Hello World"); // Password to edit the pdf pdf.SecuritySettings.OwnerPassword = "123password"; // Password to open the pdf pdf.SecuritySettings.UserPassword = "password123"; pdf.SaveAs("protected.pdf"); Imports IronPdf Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Secret Information:</h1> Hello World") ' Password to edit the pdf pdf.SecuritySettings.OwnerPassword = "123password" ' Password to open the pdf pdf.SecuritySettings.UserPassword = "password123" pdf.SaveAs("protected.pdf") $vbLabelText $csharpLabel The result is the following PDF which you can view by typing the password password123. Open a PDF that has a Password This section describes how to open a PDF that has a password. The PdfDocument.FromFile method has a second optional parameter which is the password. Provide the correct password to this parameter to open the PDF. :path=/static-assets/pdf/content-code-examples/how-to/pdf-permissions-passwords-open-password.cs using IronPdf; var pdf = PdfDocument.FromFile("protected.pdf", "password123"); //... perform PDF-tasks pdf.SaveAs("protected_2.pdf"); // Saved as another file Imports IronPdf Private pdf = PdfDocument.FromFile("protected.pdf", "password123") '... perform PDF-tasks pdf.SaveAs("protected_2.pdf") ' Saved as another file $vbLabelText $csharpLabel Advanced Security and Permissions Settings The PdfDocument object also has MetaData fields you may set such as Author and ModifiedDate. You can also disable User Annotations, User Printing, and many more as shown below: :path=/static-assets/pdf/content-code-examples/how-to/pdf-permissions-passwords-advanced.cs using IronPdf; // Open an Encrypted File, alternatively create a new PDF from HTML var pdf = PdfDocument.FromFile("protected.pdf", "password123"); // 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; // Save the secure PDF pdf.SaveAs("secured.pdf"); Imports IronPdf ' Open an Encrypted File, alternatively create a new PDF from HTML Private pdf = PdfDocument.FromFile("protected.pdf", "password123") ' 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 ' Save the secure PDF pdf.SaveAs("secured.pdf") $vbLabelText $csharpLabel The permissions setting is related to the document password and behaves as follows. For example, setting the AllowUserCopyPasteContent property to false is intended to prevent copy/paste of content: No password set: Without a password, copy/paste of content remains blocked. User password set: When a user password is set, entering the correct password will allow copy/paste of content. Owner password set: When an owner password is set, entering only the user password will not unlock the copy/paste feature. However, entering the correct owner password will allow copy/paste of content. A closely related article discusses predefined and custom metadata. Learn more by following this link: "How to Set and Edit PDF Metadata." Ready to see what else you can do? Check out our tutorial page here: Sign and Secure PDFs Frequently Asked Questions How can I protect a PDF with a password in C#? You can use IronPDF to protect a PDF with a password in C#. Download the IronPDF library from NuGet, then set the OwnerPassword to prevent editing and the UserPassword to prevent unauthorized opening. Finally, encrypt the PDF with 128-bit encryption. What is the difference between a user password and an owner password in PDF security? In PDF security, a user password is required to open the document, whereas an owner password controls permissions like editing, printing, and other actions. IronPDF supports both types of passwords to ensure comprehensive document protection. How do I open a password-protected PDF using C#? To open a password-protected PDF using C#, you can use IronPDF's PdfDocument.FromFile method, providing the correct password as a second parameter to access the document. What encryption level does IronPDF support for securing PDFs? IronPDF supports 128-bit encryption for securing PDFs, providing a robust level of protection for sensitive documents. This ensures that your PDFs are safe from unauthorized access. Can I control PDF permissions like printing and annotations using C#? Yes, with IronPDF, you can control PDF permissions such as printing and annotations by setting properties like AllowUserAnnotations and AllowUserPrinting in the SecuritySettings of the PdfDocument. How can I customize PDF metadata using IronPDF? IronPDF allows you to customize PDF metadata by setting fields such as Author and ModifiedDate. You can configure these metadata fields to enhance the document's details and security. What are the advantages of using IronSecureDoc over yearly PDF security subscriptions? IronSecureDoc offers a cost-effective solution for managing digital signing, redaction, encryption, and protection with a one-time payment, as opposed to recurring yearly subscriptions. This can be a more economical choice for businesses. How does setting an owner password affect PDF user permissions? Setting an owner password in IronPDF allows you to control user permissions. For instance, even if a user password is set, entering only the user password won't unlock certain features like copy/paste, unless the correct owner password is also provided. Where can I find more documentation on PDF security features? More documentation on PDF security features, including managing SaaS services like IronSecureDoc, can be found on IronSoftware's documentation page, providing detailed information and instructions. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Free NuGet Download Total downloads: 14,947,121 View Licenses