小孩子的教育很重要,不要为了那几个臭钱,就耽误了小孩的教育,因为教育的结果,远远大于那几个臭钱 ---------------某名人
world转换pdf,有好几种框架
aspose-world,它是目前最好用的
这里提供了他的去水印jar :)
https://learningfriend.cn:8081/test/aspose-words-15.8.0-jdk16.jar
备用 百度网盘 请输入提取码 提取码: bgat
Idea引用外部jar包,参考我的这篇文章
将本地jar包打包至springBoot中,再进行打包_我要用代码向我喜欢的女孩表白的博客-CSDN博客_springboot 打包本地jar
编写程序
package com.example.etf;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import com.aspose.words.Document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
public class EtfApplicationTests {
public static void main(String[] args) {
doc2pdf("C:\\Users\\庞振华\\Desktop\\jiekou.doc","C:\\Users\\庞振华\\Desktop\\jiekou1.pdf");
}
public static void doc2pdf(String inputDoc,String outPdf){
try {
//不加这个许可证过期的编号,转换出来第一行有红色的字
String s = "<License><Data><Products><Product>Aspose.Total for Java</Product><Product>Aspose.Words for Java</Product></Products><EditionType>Enterprise</EditionType><SubscriptionExpiry>20991231</SubscriptionExpiry><LicenseExpiry>20991231</LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber></Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature></License>";
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
License license = new License();
//设置后,转换出来不会提示过期
license.setLicense(is);
//读取world
Document document = new Document(inputDoc);
//输出Pdf
document.save(new FileOutputStream(new File(outPdf)),SaveFormat.PDF);
} catch (Exception e) {
e.printStackTrace();
}
}
}
不加s的输出会有这个

按照我的代码复制了,就没有红色的提示:)
运行测试:

参考文章:
用java实现word转pdf - 四叶草的诗雨 - 博客园
Java使用word文档转换图片或pdf格式(aspose-words),无水印,亲测有效!!!_一朵可爱的霸王fa的博客-CSDN博客_aspose.words无水印
版权声明:本文为qq_38403590原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。