Я получаю следующее исключение при настройке шифрования для PDF.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/bouncycastle/asn1/ASN1Primitive
Ниже приведен код -
public void manipulatePdf(String src, String dest) throws IOException, DocumentException {
PdfReader reader = new PdfReader(src);
int n = reader.getNumberOfPages();
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
HashMap<String, String> info = reader.getInfo();
info.put("Title", "Accessible Itext PDF");
info.put("Subject", "Itext PDF");
info.put("Keywords", "Itext");
info.put("Creator", "Me");
info.put("Author", "Me");
stamper.setMoreInfo(info);
stamper.setEncryption(USER_PASSWORD.getBytes(),OWNER_PASSWORD.getBytes(), PdfWriter.ALLOW_PRINTING,PdfWriter.ENCRYPTION_AES_128);
PdfContentByte pagecontent;
for (int i = 0; i < n; ) {
pagecontent = stamper.getOverContent(++i);
ColumnText.showTextAligned(pagecontent, Element.ALIGN_RIGHT,
new Phrase(String.format("page %s of %s", i, n)), 550, 20, 0);
}
stamper.close();
reader.close();
}
Я добавил внешние файлы Itext 5.5.9, bcprov-jdk16-146, bcmail-jdk16-146, bctsp-jdk16-146, но я все еще получаю сообщение об ошибке.