I am trying to convert doc to pdf using Apache POI, but the resulting pdf document contains only text, it is not having any formating like images, tables alignment etc.
As an alternative to POI (but still in the Java domain), you might consider docx4j (which I lead/maintain).
For docx files, docx4j can convert to PDF by converting first to FO, and then using FOP to convert to PDF.
For legacy binary doc files (as well as docx files), we have a high performance commercial solution. You can try that at http://converter-eval.plutext.com/plutext/converter, or get more info at http://www.plutext.com/m/index.php/products-docx-to-pdf.html