参考:
记一次文件从Word转为PDF(documents4j和aspose)_青语的博客-CSDN博客
Java实现windows,linux服务器word,excel转为PDF;aspose-words,documents4j_爱是与世界平行-CSDN博客
Aspose.Words 新版本发布【附下载】_weixin_34032779的博客-CSDN博客
aspose-words
com.aspose
aspose-words
15.8.0
documents4j
package org.jeecg.modules.demo.utils;
import com.aspose.words.document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import java.io.*;
import org.springframework.core.io.ClassPathResource;
public class WordPdfUtils {
public static boolean getLicense() {
boolean result = false;
try {
ClassPathResource classPathResource = new ClassPathResource("license.xml");
License aposeLic = new License();
aposeLic.setLicense(classPathResource.getInputStream());
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static boolean doc2pdf(InputStream inputStream, OutputStream outputStream) {
if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
return false;
}
try {
document doc = new document(inputStream);
doc.save(outputStream, SaveFormat.PDF);
} catch (Exception e) {
}
return true;
}
}
resources下license.xml可以去除水印
内容:
Aspose.Total for Java Aspose.Words for Java Enterprise 20991231 20991231 8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7 sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=



