// 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();

+ Recent posts