Unused bits are set to one. You can feed it to setEncryption() and it will work.
Paulo ----- Original Message ----- From: "Michael Schierl" <[EMAIL PROTECTED]> To: <itext-questions@lists.sourceforge.net> Sent: Sunday, July 08, 2007 7:21 PM Subject: [iText-questions] PdfReader#getPermissions() returns strange results > Hello, > > I thought that PdfReader#getPermissions returns the permissions used when > encrypting a document, in the same format as > PdfEncryptionSettings#setEncryption wants them. However, I only get > strange > results. For example, a document without any permissions (like the one > created in the code below) will have permissions of -64 and not 0 as I > used > for creating it. > > Bug or feature? > > Michael > > Example code: > ----- > import java.io.FileOutputStream; > import com.lowagie.text.*; > import com.lowagie.text.pdf.*; > > public class StrangePermissions { > public static void main(String[] args) throws Exception { > Document d = new Document(); > PdfWriter w = PdfWriter.getInstance(d, new FileOutputStream("test.pdf")); > w.setEncryption(new byte[0], "Test".getBytes("ISO-8859-1"), > 0, PdfWriter.STANDARD_ENCRYPTION_40); > d.open(); > d.add(new Chunk("Hello, World!")); > d.close(); > PdfReader r = new PdfReader("test.pdf", "Test".getBytes("ISO-8859-1")); > System.out.println(r.getPermissions()); // returns -64 > } > } ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/