Tech Specs
How-to C#
How-to VB.NET
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Password: Set File Permissions
Home ›› XDoc.PDF ›› C# PDF: Set File Permissions

C#.NET PDF SDK - Set PDF File Permissions in C#.NET

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

Look for HTML5 PDF Editor?

EdgePDF: ASP.NET PDF Editor is the best HTML5 PDF Editor and ASP.NET PDF Viewer based on XDoc.PDF, JQuery, HTML5. It supports ASP.NET MVC and WebForms projects.

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

Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:


       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.


       If using x86, the platform target should be x86.

        #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);

.NET Class Namespace Required

Add necessary references:









Use corresponding namespaces;

  using RasterEdge.Imaging.Basic;

  using RasterEdge.XDoc.PDF;