Could someone explain how to use Document.EncryptAs() in more detail?
Here is the method signature:
public boolean EncryptAs( String dst, String upswd, String opswd, int perm, int method, byte id )
And here is the parameter list from the Javadoc:
dst - path to save, same as path parameter of SaveAs.
upswd - user password, can be null.
opswd - owner password, can be null.
perm - permission to set, same as GetPermission() method.
bit 1-2 reserved
bit 3(0x4) print
bit 4(0x8) modify
bit 5(0x10) extract text or image
others: see PDF reference
method - reserved, currently only AES with V=4 and R=4 mode can be working.
id - must be 32 bytes for file ID. it is divided to 2 array in native library, as each 16 bytes.
Here are my main questions:
1. What is the difference between upswd and opswd? Should they be the same? Which one is used when opening the PDF?
2. What should be passed into "permission" for a standard PDF? Can you give examples?
3. What should be passed into "method"? Can you give examples?
4. What should be passed into "id"? Can you give examples? What is it used for? How will it appear in the PDF?
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.
So if I understand correctly, if you use the same password both for "user" and "owner" then the permission mask does not matter. Opening the PDF with the owner password ignores any restrictions imposed by the permission mask. Is that correct?
Does it not matter what we pass in for "encryption method"? Should we just always pass in "4"?
Should the "id" just be randomly generated 32 byte array?
Can you give an example of a typical usage of the EncryptAs() method?
sorry for the delay, we are working on it..
As soon as possible we will publish a knowledge base article about how to encrypt a pdf with a premium license and we will publish a new beta version with a fix regarding the encryption method.