i heard but not confirmed, that php can invoke java class by php-java-bridge.
so, if u using java on server, you are required to:
copy PDFAESStream class, and using PDFAESStream to encrypt PDF file.
on client, using PDFAESStream to decrypt PDF file.
sample codes:
using PDFAESStream to encrypt PDF file:
PDFAESStream stream = new PDFAESStream ();
stream.open("absolute path to new file", key);//define as file1
stream.ImportFromFile("absolute path to exists PDF file.");defile as file0
stream.close();
the codes mean create file1, if not exists.
read data from file0, and write to file1.
using PDFAESStream to open:
PDFAESStream stream = new PDFAESStream ();
stream.open("absolute path to encrypted file", key);//mean open file1.
PDFDoc doc = new PDFDoc();
doc.OpenStream(stream, null);
//do anything
doc.Close();
stream.close();//it must close after Document object closed.