通过jodconveter来实现转化。这种方式实现起来比较麻烦,操作有点繁琐,但是能解决上述问题。通过启动OpenOffice.org的服务端口,实现程序操作opeanoffice实现文件的转换。贴上代码:mportjava.io.File;importjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.io.InputStream;importjava.io.OutputStream;importcom.artofsolving.jodconverter.DefaultDocumentFormatRegistry;importcom.artofsolving.jodconverter.DocumentConverter;importcom.artofsolving.jodconverter.DocumentFormatRegistry;importcom.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;importcom.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;importcom.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;publicclasstest{/***@paramargs*/publicstaticvoidmain(String[]args)throwsException{//TODOAuto-generatedmethodstubtestt=newtest();//Filein=newFile("d:\\mytest\\test1.pdf");//Fileout=newFile("d:\\mytest\\test11.html");FileInputStreaminput=newFileInputStream("d:\\mytest\\test11.pdf");FileOutputStreamoutput=newFileOutputStream("d:\\mytest\\test11.doc");t.convert(input,output);}publicvoidconvert(Fileinput,Fileoutput)throwsException{OpenOfficeConnectionconn=newSocketOpenOfficeConnection("localhost",8100);conn.connect();DocumentConverterconverter=newOpenOfficeDocumentConverter(conn);converter.convert(input,output);conn.disconnect();}publicvoidconvert(InputStreaminput,OutputStreamoutput)throwsException{OpenOfficeConnectionconn=newSocketOpenOfficeConnection("localhost",8100);conn.connect();DocumentConverterconverter=newOpenOfficeDocumentConverter(conn);DocumentFormatRegistryregistry=newDefaultDocumentFormatRegistry();converter.convert(input,registry.getFormatByFileExtension("pdf"),output,registry.getFormatByFileExtension("doc"));conn.disconnect();}}