In the early stage, I made a PDF document reader. Recently, the company has a project that needs to convert the DOC document into a PDF document. The thread is used. [Java] import java. io. file; import java.net. connectException; import java. util. date; import com. artofsolving. jodconverter. documentConverter; import com. artofsolving. jodconverter. openoffice. connection. openOfficeConnection; import com. artofsolving. jodconverter. openoffice. connection. socketOpenOfficeConnection; import com. artofsolving. jodconverter. openoffice. converter. openOfficeDocumentConverter ;/** * Convert an office File to a pdf File * @ author zhouhuiqiang **/public class Doc2Pdf {private static boolean docToPdf (File inputFile, File outputFile) using openoffice tools) {// connect to an OpenOffice.org instance running on port 8100 OpenOfficeConnection connection = new SocketOpenOfficeConnection ("127.0.0.1", 8100); try {connection. connect (); // convert System. out. println ("START conversion document" + inputFile. getName () + "into pdf"); lead E NtConverter converter = new OpenOfficeDocumentConverter (connection); converter. convert (inputFile, outputFile);} catch (ConnectException cex) {cex. printStackTrace (); return false;} finally {// close the connection if (connection! = Null) {connection. disconnect (); connection = null;} return true;} class program thread extends java. lang. thread {public File inputFile; public File outputFile; public void run () {docToPdf (inputFile, outputFile); System. out. println (outputFile. getName () + "File generated") ;}} public void startWorkWithThread (String inputFileName, String outPutFileName) {File inputFile = new File (inputFileName); File output File = new File (outPutFileName); jsonthread t1 = new jsonthread (); t1.inputFile = inputFile; t1.outputFile = outputFile; t1.start ();} /*** convert a document to a pdf file in convertible doc format, xls * @ param inputFileName convert the source file, full path * @ param outPutFileName convert the target file, full path * @ return success */www.2cto.com public static boolean doc2pdf (String inputFilePath, String outPutFilePath) {File inputFile = new File (inputFilePath); if (inputFile. exists () {File OutputFile = new File (outPutFilePath); return docToPdf (inputFile, outputFile);} else {System. out. println ("File:" + inputFilePath + "does not exist! ") ;}Return false ;}}