First, you made the mistake of using list.size instead of list.size(). Since the property "size" does not exist, it will throw an error. Only the method size() exists. Second, you should make sure there is something in the list before checking value within it. Thus, I switched your if statement.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Problem with null pointer exception in dao layer