Tuesday, July 22, 2014

Set Password in PDF in Jasper Report

Following code snip can be used to create protected PDF. This authentication is enabled in jasper report 5.6 onward.

   SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
                
  configuration.setEncrypted(true);
  configuration.set128BitKey(true);
  configuration.setUserPassword("jasper");
  configuration.setOwnerPassword("reports");
  configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING);
  exporter.setConfiguration(configuration);
  exporter.exportReport(); 

Friday, July 11, 2014

Change default JAVA path

Once you installed JAVA 1.7 or 1.8, your default JAVA path is changed. But, it is not listed in Environment Variable Properties. To change to another JAVA path, you can simply do the following.

In Windows,

  1. go to "C:\Windows\System32" 
  2. delete "java.exe"
  3. add JAVA path to environment variable
  4. open command prompt
  5. check JAVA version (java -version)