Check out the JODConverter library (which uses OpenOffice in server mode to perform document format conversions). Or, if you want to code this yourself, you can use Apache POI to read Doc/Docx files and iText to create PDF files.
Don't get me started about those stupid light bulbs.