Monday, June 25, 2012

Wanted to generate PDF and MS Excel Reports within Java application?


Do you want to develop a reporting capability within java based application? I have shared my knowledge/experience on reporting projects which I have worked earlier. Happy to hear if from you if you have any concerns/suggestions.

To work with PDF Reports:

We have used FOP and iText earlier (not both in a same project) to create a pdf report using Java. Please read the below for each of its pros and cons.

FOP:
It is an open source Java API to create a PDF report dynamically in a template format. If you have a XML data and formatting object template (xsl), creating PDF report using FOP is very easy.  I would say only 3 lines of code will help you to create a PDF report.

XSLFO is a XSL formatting objects and can be used for formatting XML data and to generate PDF report. Using FOP, it is easy for us to generate a read-only pdf. At the same time, we can’t alter an existing pdf or we can’t apply any security within a pdf using FOP. Want to know more? Have a look @ http://www.codeproject.com/Articles/37663/PDF-Geneartion-using-XSLFO-and-FOP

iText:

It is an open-source and more powerful java api for creating a PDF file using java. Using iText, developers can create a PDF file with digital signature and security (including having permission for opening a document, print/copy the pdf). In addition to that, we can manipulate, split and concatenate the existing PDF(s) within Java program. Also, we can build a form within PDF document. Good set of working examples are available @ http://itextpdf.com/

You can choose the right framework to address your pdf needs.


To work with Excel Reports:

We have used POI and JExcel earlier (not both in a same project) to create a Microsoft   xls (spread sheet) report using Java. Please read the below for each of its pros and cons.

POI:
It is an open source Java API to read/write/modify Excel spread sheets dynamically if you have a template already (xsl). Say implementing the POI will be very easy if you already have the xml data response and xsl template for your report. As I understand, POI is not improved as much like JExcel in terms of protecting the xls spread sheet data. Want to learn more, please look at http://poi.apache.org

JExcel:
It is an open source Java API to read/write/modify Excel spread sheets dynamically. If you want to apply security OR to derive a new data (Sum, average etc) using the existing data, JExcel will be the right option. It is a Java API, we wanted to write Java code for column alignment, font, style etc.  Also, it supports copying charts and images into excel sheet. Want to know more? Visit http://jexcelapi.sourceforge.net/

If you unable to follow the examples used in the above links, any issues or sample codes, reach put to me.

_NjN

Saturday, June 23, 2012

“Lines of Code” Calculator


Are you finding difficulty in calculating “Lines of Codes” written in java based application? I can strongly recommend the open source tool “LOC Calculator” to do the same. It comes with very simple UI screen which is used to calculate the LOC in 10 seconds of time. Sounds interesting? Try the LOC calculator @ http://code.google.com/p/loc-calculator/


Cheers,
_NjN

Friday, June 1, 2012

Password Encryption (Hex Code) using java


In my early blog (http://nanjundanonlinedictonary.co.in/2012/02/password-encryprion-using-java.html), I had articulated the easy way of password encryption using java. The program would result an encrypted text in a hash format but not in a hex code as we can see in Spring ACEGI framework. Here in this article, we are specifically focus on possibilities to convert SHA hash password SHA hex password.

Old Code:
  
byte rawBytes[] = md.digest();
String hashPassword = (new BASE64Encoder()).encode(rawBytes);
  

New Code:

byte rawBytes[] = md.digest();
StringBuffer strBuffer = new StringBuffer();
      for (byte rawByte : rawBytes) {
        strBuffer.append(Integer.toHexString((int) (rawByte & 0xff)));
      }
String hexText = strBuffer.toString();

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...