// make pdf
byte[] pdfOutput = makePdf();
os.write(pdfOutput);
os.close();
//pdf encryption
PDDocument pdd = PDDocument.load(os.toByteArray());
AccessPermission ap = new AccessPermission();
StandardProtectionPolicy stpp = new StandardProtectionPolicy(password, password, ap);
stpp.setEncryptionKeyLength(128);
stpp.setPermissions(ap);
pdd.protect(stpp);
pdd.save(os);
pdd.close();
java pdf 암호화
2022. 4. 19. 19:30