How Can i convert word,text document into pdf

How Can i convert word,text document into pdf
Hello,
my aim is to convert word/text document, into pdf document on srver side.
Means if user upload a doc or docx file into server then this file is automatically convert into pdf document. how can it is possible.
please help me.