This article shows how to Encrypt a pdf.
This feature is available only with Premium License.
// Source PDF
String path1 = "/sdcard/test.pdf";
// New encrypted PDF path
String path2 = "/sdcard/test_encrypted.pdf";
// Opening the file and encrypting the PDF with permissions
byte id = "123456789abcdefghijklmnopqrstuvw".getBytes();
Document doc = new Document();
System.out.println("Log - Encrypt : " + doc.EncryptAs(path2, "userPwd", "ownerPwd", 4, 4, id));
Here some more detailed explanation of the EncryptAs( String dst, String upswd, String opswd, int perm, int method, byte id ) parameters:
dst: path to save, same as path parameter of SaveAs
user password: is the public password (shared with authorized users). It's sufficient to open the file with applied permission mask set.
owner password: is the password that allow opening the file without any restriction from the permission mask.
permission mask is defined as per below image: the table has been taken from pdf_reference_1-7.pdf, the official PDF definition from Adobe.
encryption method: always equal to 4. RadaeePDF actually support only AES encrypted output.
id is something like the encryption seed or salt is some other encryption scheme. That id is a reserved code that make password stronger.
RadaeePDF SDK for Android
Created : 2015-08-04 10:08:02, Last Modified : 2016-01-21 10:19:38