

Instantiate the StandardProtectionPolicy class by passing the owner password, user password, and the AccessPermission object as shown below. Step 3: Creating StandardProtectionPolicy Object Instantiate the AccessPermission class as shown below.ĪccessPermission accessPermission = new AccessPermission() Step 2: Creating Access Permission Object PDDocument document = PDDocument.load(file) This method accepts a file object as a parameter, since this is a static method you can invoke it using class name as shown below.įile file = new File("path of the document") Load an existing PDF document using the static method load() of the PDDocument class. The StandardProtectionPolicy class is used to add a password based protection to a document.įollowing are the steps to encrypt an existing PDF document. Extract text and graphics for accessibility to visually impaired people.Copy or extract content of the document.Using this class, you can restrict users from performing the following operations.

The AccessPermission class is used to protect the PDF Document by assigning access permissions to it. You can encrypt a PDF document using the methods provided by StandardProtectionPolicy and AccessPermission classes. In this chapter, we will discuss how to encrypt a PDF document. In the previous chapter, we have seen how to insert an image in a PDF document.
