通过jodconveter来实现转化(http://www.artofsolving.com/opensource/jodconverter)。这种方式实现起来比较麻烦,操作有点繁琐,但是能解决上述问题。通过茄举启动OpenOffice.org的服务端口,实现程序操作opeanoffice实现文件的转换。 贴上颤御碧代码:mport java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import com.artofsolving.jodconverter.DefaultDocumentFormatRegistry; import com.artofsolving.jodconverter.DocumentConverter; import com.artofsolving.jodconverter.DocumentFormatRegistry; import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; public class test { /** * @param args */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub test t = new test(); //File in = new File("d:\\mytest\\test1.pdf"); //File out = new File("d:\\mytest\\test11.html"); FileInputStream input = new FileInputStream("拆键d:\\mytest\\test11.pdf"); FileOutputStream output = new FileOutputStream("d:\\mytest\\test11.doc"); t.convert(input, output); } public void convert(File input, File output) throws Exception { OpenOfficeConnection conn = new SocketOpenOfficeConnection("localhost", 8100); conn.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(conn); converter.convert(input, output); conn.disconnect(); } public void convert(InputStream input, OutputStream output) throws Exception { OpenOfficeConnection conn = new SocketOpenOfficeConnection("localhost", 8100); conn.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(conn); DocumentFormatRegistry registry = new DefaultDocumentFormatRegistry(); converter.convert(input, registry.getFormatByFileExtension("pdf"), output, registry.getFormatByFileExtension("doc")); conn.disconnect(); } }
相关文章
-
brother HL-2140 1个文档待打印,原因为Administrator
2023-10-30 08:29 阅读(556) -
2007word的背景色怎么调成白色
2023-10-29 14:19 阅读(618) -
不打开word,如何搜索文档内容里面的关键字
2023-10-29 13:49 阅读(599)
1 怎样用word做答题卡
616 阅读
2 word文档2010怎么免费下载
615 阅读
3 中国地质大学长城学院教务系统大学成绩单word表格
656 阅读
4 怎么从手机上把金山文档的文件转成excel
574 阅读
5 word文档操作:本段文字添加10%灰色底纹
600 阅读