Encryption & permissions v10.0.0

PDF Security for .NET

The ExpertPdf PDF Security library manages the security settings of PDF documents in any .NET application, ASP.NET web sites or Windows Forms applications. Encrypt the content, set user and owner passwords, and control what readers may do: print, copy, assemble the document, fill forms, edit the content or the annotations.

Choose a 40, 128 or 256 bit key and the RC4 or AES algorithm, remove all the security settings with the user or owner password, and sign documents with a PFX certificate. It is a .NET assembly you reference in your application, with no installation.

NuGet · ExpertPdf.PdfSecurity C# & VB.NET samples included
Encryption RC4 or AES · 40, 128, 256 bit
Controls Passwords, permissions, signatures
Targets .NET Framework to .NET 11

Everything PDF Security does.

Grouped by how a PDF document is protected: who can open it, what readers can do once it is open, and who signed it.

Encryption

Lock the document.

User and owner passwords, a 40, 128 or 256 bit key, the RC4 or AES algorithm, applied to existing PDF documents and removed again with a password.

User password

The password required to open the PDF document.

Owner password

The password required to change the permissions of the document, such as printing or editing.

RC4 or AES, 40 to 256 bit

Encrypt the content with the RC4 or AES algorithm and a 40, 128 or 256 bit key. The defaults are AES and a 128 bit key.

Secure existing PDFs

Apply the security settings to a PDF file, or to a PDF document in memory as an array of bytes, for example one produced by another PDF tool.

Remove the security

Remove all the security settings of a document by giving its user or owner password.

AES-256 and non-ASCII passwords

AES-256 is written as revision 6 (ISO 32000-2), and passwords in any language work. The document information is kept when securing or unsecuring.

Permissions

Control what readers can do.

Each permission is a property of PdfSecurityOptions that allows or denies one operation.

Printing

Allow or deny printing with CanPrint, and printing in full quality with CanFullQualityPrint.

Copying

Allow or deny copying the content with CanCopyContent, and copying it for accessibility with CanAccessibilityCopyContent.

Editing

Allow or deny editing the content of the document with CanEditContent.

Forms and annotations

Separate permissions for filling form fields (CanFillFormFields) and editing annotations (CanEditAnnotations).

Document assembly

Allow or deny creating bookmarks and thumbnails and inserting, rotating or deleting pages, with CanAssembleDocument.

Signatures & tools

Sign the document.

Sign a PDF document with a PFX certificate, with an optional time stamp, or manage security from the command line.

Digital signatures

The Sign method signs a PDF document with a PFX certificate and its password.

Signature details

Give the signature name, the reason, the location and the contact information, and place the signature on a page, in a rectangle.

Certification signatures

Certify a document as its author, and choose what may change afterwards: nothing, form filling, or form filling and annotations.

Empty signature fields

Add a signature field that a later Sign call with the same name fills in.

In memory and protected sources

Sign from a stream to a stream or from bytes to bytes, and sign or validate password-protected documents with SourcePdfPassword.

Time stamp server

Add a time stamp from a time stamp server, with its address, user name, password and timeout, using TimeStampAuthority.

Validate signatures

ValidateSignatures checks integrity, whole-document coverage, the certificate and its chain, the time stamp and, optionally, revocation, for every signature.

Read the security settings

GetSecurityInfo reports encryption, algorithm and key size, permissions, required passwords and signatures, without changing the file.

Command line sample

A command line sample, with its C# and VB.NET source for .NET Framework and a .NET 10 version, applies or removes the security settings of PDF documents.

A PDF, locked down.

The PdfSecurityManager and PdfSecurityOptions classes: secure a file, remove the security, and secure a PDF document in memory. All the properties and methods are in the API reference.

Program.cs · C#
using ExpertPdf.PDFSecurity;

var options = new PdfSecurityOptions();
options.UserPassword = "user-password";
options.OwnerPassword = "owner-password";
options.Algorithm = EncryptionAlgorithm.AES;
options.KeySize = EncryptionKeySize.EncryptKey256Bit;

// What a reader may do with the document
options.CanPrint = true;
options.CanCopyContent = false;
options.CanEditContent = false;
options.CanEditAnnotations = false;

var security = new PdfSecurityManager(options);
security.SaveSecuredPdfToFile("contract.pdf", "contract-secured.pdf");

The download includes C# and VB.NET samples. Install from NuGet with dotnet add package ExpertPdf.PdfSecurity, or read the developer's guide.

Security questions, answered.

Common questions about passwords, encryption, permissions and signatures.

What is the difference between the user password and the owner password?
The user password is required to open the document. The owner password is required to change permissions such as printing or editing. If you set only the user password, it is also used as the owner password, and a reader who opens the document with it can do everything.
Which encryption algorithms and key lengths are supported?
The RC4 and AES algorithms, with 40, 128 or 256 bit keys. Set them with the Algorithm and KeySize properties of PdfSecurityOptions. The defaults are AES and a 128 bit key.
Can I secure PDF documents that already exist?
Yes. PdfSecurityManager applies the security settings to an existing PDF document, given as a file or as an array of bytes. The in-memory methods work with PDF documents produced by other tools.
Can I remove the security from a PDF document?
Yes. SaveUnSecuredPdfToFile and GetUnSecuredPdfBytes remove all the security settings when you give them the user or the owner password of the document.
Which permissions can I set?
Printing (CanPrint) and full quality printing (CanFullQualityPrint), copying the content (CanCopyContent) and copying it for accessibility (CanAccessibilityCopyContent), editing the content (CanEditContent), editing annotations (CanEditAnnotations), filling form fields (CanFillFormFields), and assembling the document: bookmarks, thumbnails, inserting, rotating or deleting pages (CanAssembleDocument). Filling form fields and assembling the document take effect with a 128 bit key.
Can it sign PDF documents?
Yes. The Sign method signs a PDF document with a PFX certificate, from a file, a stream or a byte array. You give the signature name, the reason, the location and the contact information, the page and the rectangle of the signature, and optionally a time stamp server. Set CertificationLevel to certify the document (no changes, form filling, or form filling and annotations allowed afterwards), and use AddSignatureField to add an empty signature field that a later Sign call fills in.
Can it check the signatures of a document?
Yes. ValidateSignatures checks every signature: whether the document changed after signing, whether the signature covers the whole document, the certificate at signing time, the certificate chain, the time stamp and, optionally, revocation. Each result has a Status of Valid, Unknown or Invalid.
Can I read the security settings of a document without changing it?
Yes. GetSecurityInfo returns whether the document is encrypted, the algorithm, key size and revision, the permissions, which passwords it needs, and whether it is signed or certified.
Is there a ready-to-use tool?
Yes. The download includes a command line sample, with its C# and VB.NET source for .NET Framework and a .NET 10 version, that applies or removes the security settings of PDF documents.
Does it need an installation?
No installation is necessary. Install the ExpertPdf.PdfSecurity package from NuGet, or copy epsecurepdf.dll from the download to the bin folder of your application and reference it.
Which .NET versions and operating systems are supported?
.NET Framework and .NET Core / .NET 5 to .NET 11 (through .NET Standard 2.0), with assemblies for .NET Framework 2.0 and 4.0 and for .NET Standard 2.0, in ASP.NET web sites, Windows Forms and console applications. The library runs on Windows. An x64 optimized package, ExpertPdf.PdfSecurity.x64, is also available for applications that run as x64 processes.
Is there a free version I can try?
Yes. Download the free evaluation with C# and VB.NET samples. The licensed development library is royalty free.

Protect PDF documents in .NET.

Download the free evaluation with C# and VB.NET samples and the command line tool. When you are ready, license it on the pricing page.

Targets.NET Framework · .NET Core · .NET 5 to 11
Versionv10.0.0