PDF Protect

Protect PDF documents with free cross-platform Apps and APIs

How to Protect PDF File Using Aspose.PDF Library

In order to protect PDF file, we’ll use Aspose.PDF API which is a feature-rich, powerful and easy to use document manipulation API. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console. You can use the Encrypt method of the Document object to encrypt a PDF file. You can pass the user password, owner password, and permissions to the Encrypt method. In addition to that, you can pass any value of the CryptoAlgorithm enum. This enum provides different combinations of encryption algorithms and key sizes. You can pass the value of your choice. Finally, save the encrypted PDF file using Save method of the Document object.

High Code APIs to Add or Remove Electronic Signatures from Document


Native APIs to e-sign PDF files using .NET, .NET Core, Java, C++ & Android.

Encrypt PDF File

This sample code shows how to encrypt PDF File

// Open document
Document document = new Document(dataDir+ "Encrypt.pdf");
// Encrypt PDF
document.Encrypt("user", "owner", 0, CryptoAlgorithm.RC4x128);
dataDir = dataDir + "Encrypt_out.pdf";
// Save updated PDF
document.Save(dataDir);