I found that encrypt() has implemented full support to user access permissions P, but it does not allows the caller to assign any permission. I have to change the value of P manually in pdf.py. BTW, The current encrypt() set P = -1 to enable all operations, but it should be P = -4 because the 1st and the 2nd bits have to be 0 according to PDF reference.