atmaling Posted September 8, 2010 Share Posted September 8, 2010 Hi,How to create password protected PDF ?? I tried following code but got the Exception as : java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1OctetString JasperReport jr=JasperCompileManager.compileReport("E:\\report1.jrxml"); JasperPrint jp=JasperFillManager.fillReport(jr,new HashMap(),connection); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_FILE,new File("E:\\report1.pdf")); exporter.setParameter(JRPdfExporterParameter.OWNER_PASSWORD, "hi"); exporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, "hi"); exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE); exporter.exportReport(); Having following jars iText-2.1.0.jar jasperreports-3.6.0.jar commons-beanutils.jar commons-collections.jar commons-digester.jar commons-digester-1.7.jar commons-logging.jar groovy-all-1.5.5.jar ojdbc14.jarNot getting more help from anywhere. Plzz help me.Thanks in Advance Link to comment Share on other sites More sharing options...
szaharia Posted September 8, 2010 Share Posted September 8, 2010 It seems to be a requirement from your specific app environment. Try to add to app classpath one of the jdk-related bcprov jars here.Hope this helps,sanda Link to comment Share on other sites More sharing options...
Solution atmaling Posted October 14, 2010 Author Solution Share Posted October 14, 2010 Solution foundbcprov-jdk16-145.jar file was missing, downloaded from Include jar file in lib or classpath folder.Below is the list of all required jarsjasperreports-3.7.0.1.jarcommons-io-1.3.1.jarcommons-logging-1.0.4.jarcommons-collections-3.2.jarcommons-digester-1.7.jarcommons-beanutils-1.8.0.jargroovy-all-1.5.5.jaritext-2.1.0.jarbcprov-jdk16-145.jar Below find my codeCode:Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:atm","uid","pwd"); JasperReport jr=JasperCompileManager.compileReport("E:\\Atmaling\\my_programs\\pwdReport.jrxml"); JasperPrint jp=JasperFillManager.fillReport(jr,new HashMap(),con); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_FILE,new File("E:\\Atmaling\\my_programs\\pwdReport.pdf")); exporter.setParameter(JRPdfExporterParameter.OWNER_PASSWORD, "hi"); exporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, "hi"); exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE); exporter.exportReport(); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now