I am trying to generate a password protected PDF file using JasperReports and Java.
Code is as follows:
jrPdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path.concat(filename).concat(".pdf"));
jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jprint);
jrPdfExporter.setParameter(JRPdfExporterParameter.OWNER_PASSWORD, "Bancosol123");
jrPdfExporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, "Bancosol123");
jrPdfExporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE);
jrPdfExporter.exportReport();
I was using iText 2.1.7 to generate the PDF, it was working fine, but when I included the password part, I got the error
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
I included the following two jars:
bcprov-jdk15on-1.47.jar
bcmail-jdk15on-1.47.jar
But the issue still was not solved. I read somewhere it might be a compatibility issue with iText 2.1.7
So I removed iText 2.1.7 and included iText 5.3.2
Now I have the following error
exception in thread "awt-eventqueue-0" java.lang.noclassdeffounderror: com/lowagie/text/documentexception