Configuring a SessionFactory is a heavy weight operation. You should only do it once (or in your case, twice) in one application. Creating one on the fly to run a query is wasteful and likely to be slow.
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