word转出图片(使用免费插件)03
来源:互联网 发布:游戏美工原画招聘 编辑:程序博客网 时间:2024/06/01 10:49
word转图片:
2.word转pdf用的OpenOffice,pdf转图片icepdf。
我在mac系统运行的,用命令行打开OpenOffice服务
mac的命令行:
odconverter-core cd /Applications/OpenOffice.app/Contents/program program ./soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
win系统不用这么麻烦
这个转换pdf方法,word两种格式都兼容,pdf转图片还是用的word转出图片(使用免费插件)02中的转换方法,大家有更多的好方法留言交流。
public static int office2PDF(String sourceFile, String destFile) {
try {
File inputFile = new File(sourceFile);
if (!inputFile.exists()) {
return -1;// 找不到源文件, 则返回-1
}
// 如果目标路径不存在, 则新建该路径
File outputFile = new File(destFile);
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
String OpenOffice_HOME = "/Applications/OpenOffice.app/Contents/";//这里是OpenOffice的安装目录, 在我的项目中,为了便于拓展接口,没有直接写成这个样子,但是这样是绝对没问题的
// 如果从文件中读取的URL地址最后一个字符不是 '\',则添加'\'
// if (OpenOffice_HOME.charAt(OpenOffice_HOME.length() - 1) != '\\') {
// OpenOffice_HOME += "\\";
// }
// 启动OpenOffice的服务 -nofirststartwizard
String command = OpenOffice_HOME
+ "program/soffice -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" ";
Process pro = Runtime.getRuntime().exec(command);
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(
"127.0.0.1", 8100);
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(
connection);
converter.convert(inputFile, outputFile);
// close the connection
connection.disconnect();
// 关闭OpenOffice服务的进程
pro.destroy();
return 0;
} catch (Exception e) {
e.printStackTrace();
//return -1;
}
return 1;
}
- word转出图片(使用免费插件)03
- word转出图片(使用免费插件)01
- word转出图片(使用免费插件)02
- 关于PDF转Word转出来是图片及乱码多的解决方法分享
- 如何使用免费PDF第三方插件从PDF文档中提取文本和图片
- 图片 (免费的可商业使用的图片素材)
- Godaddy域名转出步聚 (转)
- 可以免费使用的便捷留言板插件
- cad转出高清图片的方法。分享
- 自动上传本地图片和word图片(word图片需使用从word粘贴功能)
- 使用Activex插件复制剪贴板中的word或excel内容到web HTML编辑器并自动上传图片或文件
- 使用Delphi开发Office Word插件
- 使用Delphi开发Office Word插件
- Word中使用代码高亮插件
- 免费生成二维码图片API使用
- Word插件
- 使用VC向word中插入图片
- word中使用宏批量插入图片
- React Native布局之flex
- 在Openwrt上安装alar以便进行录音,播音功能
- 深度学习之基础模型-FractalNet
- Android自定义折线图
- mysql5.7.19版本数据表名不区分大小写
- word转出图片(使用免费插件)03
- 图形学基础:第1章 颜色
- Java用MyEclipse 连接数据库
- Google Map开发系列(七)——使用谷歌地图API实现自定义控件
- 续厨师与母亲的厨艺问题的一些想法
- Android常见动画以及分类
- 使用Python机器识别库pytesseract遇到的问题
- 三道典型C语言题(3)
- 命令行编译一个简单的 VC 程序