public static void word2Html(String docfile,String htmlfile) {
ActiveXComponent app = new ActiveXComponent("Word.Application"); // 启动word
try {
app.setProperty("Visible", new Variant(false));// 设置word不可见
Object docs = app.getProperty("Documents").toDispatch();
Object doc = Dispatch.invoke((Dispatch) docs, "Open", Dispatch.Method,
new Object[] { docfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch();// 打开word文件
Dispatch.invoke((Dispatch) doc, "SaveAs", Dispatch.Method
, new Object[] { htmlfile, new Variant(8) } // 8为html格式
, new int[1]);
Variant f = new Variant(false);
Dispatch.call((Dispatch) doc, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
app.invoke("Quit", new Variant[] {});
}
}
public static void word2PDF(String inputFile,String pdfFile){
//打开word应用程序
ActiveXComponent app = new ActiveXComponent("Word.Application");
//设置word不可见
app.setProperty("Visible", false);
//获得word中所有打开的文档,返回Documents对象
Dispatch docs = app.getProperty("Documents").toDispatch();
//调用Documents对象中Open方法打开文档,并返回打开的文档对象Document
Dispatch doc = Dispatch.call(docs, "Open", inputFile, false, true ).toDispatch();
//调用Document对象的SaveAs方法,将文档保存为pdf格式
Dispatch.call(doc, "ExportAsFixedFormat",
pdfFile, new Variant(17) //word保存为pdf格式宏,值为17
);
//关闭文档
Dispatch.call(doc, "Close", false);
//关闭word应用程序
app.invoke("Quit", 0);
}
public static void main(String[] args) {
String docfile = "D:/test.doc";
String htmlFile = "D:/test.html";
String pdfFile = "D:/test.pdf";
word2Html(docfile, htmlFile);
word2PDF(docfile, pdfFile);
}
分享到:
相关推荐
关于Corba的经典教程,推荐阿,关于JAVA方面的,很好的教材
java开发corba接口MyEclipse或者Eclipse编译IDL文件为java文件的插件2
修改CLASSPATH为 .;%JAVA_HOME%\jre\lib;%JACORB_HOME%\lib\antlr-2.7.2.jar; %JACORB_HOME%\lib\backport-util-concurrent.jar;%JACORB_HOME%\lib\idl.jar; %JACORB_HOME%\lib\jacorb.jar;%JACORB_HOME%\lib\logkit...
JacORB 2.3 Programming Guide The JacORB Team February 17, 2007
jacorb-3.7 源码版
提供jacorb.jar包的下载,中间件corba的jacorb实现jar包
corba 服务器 jacORB 2.3.0
ant 打包时候之下载一个apache-ant不够,会报错找不到主类jacorb,这个就是jacorb的类,也需要配置环境变量。
JacORB-2.3.0-bin.zip JacORB-2.3.0-bin.zip JacORB-2.3.0-bin.zipJacORB-2.3.0-bin.zip
jacorb-2.3.1-bin.zip,jacorb-2.3.1-bin.zip希望大家受用!
jacorb学习材料。
jacORB 2.3.1 编程指导 此书是英文版的。
jacorb开发,主要介绍了jacorb的安装流程,在linux环境下的安装
是一款和好的基于corba的orb产品。
THE JACORB TEAM公布的官方设计手册
This document gives an introduction to programming distributed applications with JacORB, a free Java object request broker. JacORB comes with full source code, a couple of CORBA Object Service ...
jacorb的官方最近测试版本,需要的同学就下载吧
支持JAVA语言的免费CORBA中间件产品
JacORB-2.2.3-source源代码,corba IDL编译成java必备