我用這樣的密碼加密pdf:public static void main(String[] args) throws DocumentException, MalformedURLException, IOException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("zrsz.pdf")); writer.setEncryption("ownerPass".getBytes(), "userPass".getBytes(), PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128); writer.createXmpMetadata(); document.open(); document.add(new Paragraph("This is create PDF with Password demo.")); document.close(); System.out.println("Done"); }但我找不到給這個setEncryption方法一個“無權(quán)限”參數(shù)的方法:public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)甚至有可能嗎?我想將該文件的訪問權(quán)限限制在最低限度。我只是用它來讀取機密數(shù)據(jù)。提前致謝 !
1 回答

犯罪嫌疑人X
TA貢獻(xiàn)2080條經(jīng)驗 獲得超4個贊
根據(jù)手冊,您可以使用文檔所說的以下所有內(nèi)容
設(shè)置此文檔的加密選項。userPassword 和 ownerPassword 可以為 null 或長度為零。在這種情況下,ownerPassword 被隨機字符串替換。文檔的打開權(quán)限可以是 AllowPrinting、AllowModifyContents、AllowCopy、AllowModifyAnnotations、AllowFillIn、AllowScreenReaders、AllowAssembly 和 AllowDegradedPrinting
使用用戶密碼打開文檔時允許上述所有操作。所以你有一個安全措施,只有輸入有效憑據(jù)(密碼)的用戶才能操作它。
添加回答
舉報
0/150
提交
取消