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();