Go to this page and scroll down to Example 7-1 It isn't exactly what you are looking for but it gives you a start. All I did was google "java example code url" and that page was the first hit. [ November 10, 2003: Message edited by: William Barnes ]
Please ignore post, I have no idea what I am talking about.
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