当前位置:网站首页>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
边栏推荐
- 编程旅行之函数
- 多重继承虚基类习题
- What is the difference between blue-green publishing, rolling publishing and gray publishing?
- The art of automation
- Wechat applet
- Lin Lin, product manager of Lenovo: network failure of local network operator in Tianjin. The background server of Zui system can't work normally for the time being
- AtCoder Beginner Contest 248C Dice Sum (生成函数)
- Yarn online dynamic resource tuning
- Android篇:2019初中级Android开发社招面试解答(中
- YARN线上动态资源调优
猜你喜欢
随机推荐
初识go语言
SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
JS 烧脑面试题大赏
JS 力扣刷题 102. 二叉树的层序遍历
BUG_me
专题测试05·二重积分【李艳芳全程班】
visio安装报错 1:1935 2:{XXXXXXXX...
Nodejs安装及环境配置
[code analysis (6)] communication efficient learning of deep networks from decentralized data
smart-doc + torna生成接口文档
Program compilation and debugging learning record
linux MySQL数据定时dump
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
SPC简介
Spark入门基本操作
JMeter pressure test tool
PySide2
多重继承虚基类习题
mysql通过binlog文件恢复数据
centOS下mysql主从配置