当前位置:网站首页>jacob打印word
jacob打印word
2022-04-23 14:02:00 【1029179954】
一、前言
利用jacob打印word,首先需要jacob.jar和jacob.dll俩种工具,都是底层工具,会使用就可以了。打印word其实涉及一系列word的操作,比如替换文本,还是转化成pdf等等,我建议做这些工作的话利用poi操作word比较好,简单,方便。
二、工具下载
微信公众号搜索:小白XBIT
回复关键字:jacob就可以获得以上俩种的工具
三、工具的使用
1:jacob.jar
(1)将它放在安装jdk的bin目录下和jre的目录下,同时要放在web-inf的lib下面然后build一下就可以了。
(2)将它放在安装jdk的bin目录下和jre的目录下,直接放在tomcat的lib目录也可以(建议使用这种),第一种一般会造成加载冲突。
2:jacob.dll
将jacob.all放在C:\Windows\System32即可。注意根据电脑的位数放入对应的位数的dll,32和64我都提供了下载。
四、打印代码
/*
* 打印指定路径下的文档
*/
public String print(String path) {
ComThread.InitSTA();
ActiveXComponent word=new ActiveXComponent("Word.Application");
Dispatch doc=null;
Dispatch.put(word, "Visible", new Variant(false));
Dispatch docs=word.getProperty("Documents").toDispatch();
doc=Dispatch.call(docs, "Open", path).toDispatch();
try {
Dispatch.call(doc, "PrintOut");//打印
return "succ";
} catch (Exception e) {
e.printStackTrace();
return "fail";
}finally{
try {
if(doc!=null){
Dispatch.call(doc, "Close",new Variant(0));
}
} catch (Exception e2) {
e2.printStackTrace();
}
//释放资源
ComThread.Release();
}
}
版权声明
本文为[1029179954]所创,转载请带上原文链接,感谢
https://blog.csdn.net/baidu_38978508/article/details/107706976
边栏推荐
猜你喜欢
分库分表 & ShardingSphere
As a junior college student, I studied hard in closed doors for 56 days, won Ali offer with tears, five rounds of interviews and six hours of soul torture
CentOS mysql多实例部署
关于pthread多线程一些好文章
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
groutine
Record a strange bug: component copy after cache component jump
1256: bouquet for algenon
Pytorch 经典卷积神经网络 LeNet
freeCodeCamp----time_ Calculator exercise
随机推荐
Decentralized Collaborative Learning Framework for Next POI Recommendation
Choreographer全解析
【报名】TF54:工程师成长地图与卓越研发组织打造
Nacos+AspnetCore+Ocelot实战编码
Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]
go 语言 数组,字符串,切片
关于stream流,浅记一下------
生产环境——
mysql通过binlog文件恢复数据
Restful WebService和gSoap WebService的本质区别
第一章 电商秒杀商品回顾
Special test 05 · double integral [Li Yanfang's whole class]
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
What is the difference between blue-green publishing, rolling publishing and gray publishing?
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
JS 烧脑面试题大赏
groutine
Spark入门基本操作
分页SQL
visio安装报错 1:1935 2:{XXXXXXXX...