我用这样的密码加密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方法一个“无权限”参数的方法:
public void setEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
int encryptionType)
甚至有可能吗?我想将该文件的访问权限限制在最低限度。我只是用它来读取机密数据。
提前致谢 !
犯罪嫌疑人X
相关分类