PM > Install-Package XDoc.PDF

How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF File Protect Library
How to add, generate, remove PDF file permission with owner password using c# .net


Online C# Guide for How to Set PDF File Access Permissions Using XDoc.PDF for .NET in C#









  • A best PDF document SDK library for Visual Studio .NET for PDF security level settings in C#.NET framework project
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Powerful .NET components for PDF file protecting in both WinForms program and ASP.NET web application
  • Free online C# source code provides multiple ways to set PDF file permissions in C#.NET class
  • Support to create a password to PDF or delete password from PDF file
  • Help to protect PDF from printing in C#.NET
  • Help to lock and unlock PDF from copying and editing
  • Protect PDF from annotation and content extraction
  • Able to lock PDF form after filling out
  • Provide users with the ability of assembling adobe PDF document




C# apply pdf document permission settings with password


        #region apply pdf document permission settings with password
        internal static void applyPermissionSettings()
        {
            String inputFilePath = @"C:\demo.pdf";
            String outputFilePath = @"C:\demo_with_settings.pdf";

            // Create a password setting object with user password "Hello World".
            PasswordSetting passwordSetting = new PasswordSetting("Hello World");

            // Set encryption level to AES-128.
            passwordSetting.Level = EncryptionLevel.AES_128bit;

            // Printing is allowed.
            passwordSetting.IsPrint = true;

            // Print with high-resolution.
            passwordSetting.IsHighReso = true;

            // Document is allowed to be changed.
            passwordSetting.IsModify = true;

            // Annotation is allowed.
            passwordSetting.IsAnnot = true;

            // Form filling is allowed.
            passwordSetting.IsFillForm = true;

            // Content extraction is allowed.
            passwordSetting.IsExtract = true;

            // Copying is allowed.
            passwordSetting.IsCopy = true;

            // PDF document assembling is allowed.
            passwordSetting.IsAssemble = true;

            // Add password to the file.
            PDFDocument.AddPassword(inputFilePath, outputFilePath, passwordSetting);
        }
        #endregion








Common Asked Questions

How do I remove protected mode from a PDF?

You can use PDF editor program such as Adobe Acrobat, Foxit PDF, to remove the protected mode from a PDF file. Open a PDF file in Acrobat, click "Edit" from the menu bar. Click "Preferences..." from the menu or press "Ctrl + K". Click "Security (Enhanced)" from "Categories:" Choose "Off" from "Protected View" options. Using XDoc.PDF C# library, you can unlock the protected mode from a PDF file in C# code in ASP.NET Core web application.

How to enable PDF file permissions?

Open a PDF file in Acrobat, click "Tools" from toolbar. Click "Protect" from "Protect & Standardize" group. Select "Restrict Editin" to apply permission. Using RasterEdge C# PDF editor library, you can enable PDF file editing permission using C# API in ASP.NET, WinForms projects.

How to unlock PDF file permissions?

You can unlock PDF file permissions using PDF editor applications. For example, in Adobe Acrobat. Open the PDF file in Acrobat. Choose "Tools" from toolbar. Click "Protect" from "Protect & Standardize" group. Click "Remove Security" from "Encrypt". Input the attached password to unlock the file permission. Using C# PDF security library, you can unlock the file with password with one line of C# code.

How do I change the permissions on an Adobe PDF?

Open the PDF document using Acrobat. Choose "Tools" from toolbar. Click "Protect" from "Protect & Standardize" group. Click "Restrict Editing", and enter permission password. Now you can update the permission settings and save the modified PDF file. Using C# PDF library, you can edit and update the same PDF file permission settings as Acrobat in your C# ASP.NET Core, MVC web applications.

How to change PDF document restrictions?

Open PDF file in Acrobat. Click "Properties..." from "File" in menu bar, or press "Ctrl + D" to open it directly. In "Document Properties" windows, select the "Security" tab and choose "Password Security". Modfiy and apply the security options you want to enable. Using C# PDF library, you will have the same security options set to apply the security with few lines of C# code in your Visual Studio .NET projects.

How do I allow editing on a PDF file?

You can edit PDF content (information such as page, text, image, bookmark, metadata) using PDF editor applications. Such as Adobe Acrobat. Using C# PDF library, you can freely create, edit, remove text, image content from a PDF document in your ASP.NET, MVC, web forms and Windows Forms application. You can quickly build a PDF editor web page tool like Acrobat, using RasterEdge EdgePDF ASP.NET PDF editor web control.