• aspose-words去水印自用资源


    官方文档https://docs.aspose.com/words/java/convert-a-document-to-pdf/

    声明:限个人学习使用,商用后果与本人无关。

    1.引入依赖
    1. <dependencies>
    2. <dependency>
    3. <groupId>com.asposegroupId>
    4. <artifactId>aspose-wordsartifactId>
    5. <version>18.6version>
    6. <classifier>jdk16classifier>
    7. dependency>
    8. dependencies>
    9. <repositories>
    10. <repository>
    11. <id>aspose-maven-repositoryid>
    12. <url>https://artifact.aspose.com/repo/url>
    13. repository>
    14. repositories>
    2.下载依赖后去依赖仓库位置删掉从官方源下载的版本

    仓库路径/com/aspose/aspose-words/18.6

    删除路径中aspose-words-18.6-jdk16.jar文件,使用我的资源文件替换

    3.添加license.xml文件到src/main/resources目录下
    1. <License>
    2. <Data>
    3. <Products>
    4. <Product>Aspose.Total for JavaProduct>
    5. <Product>Aspose.Words for JavaProduct>
    6. Products>
    7. <EditionType>EnterpriseEditionType>
    8. <SubscriptionExpiry>20991231SubscriptionExpiry>
    9. <LicenseExpiry>20991231LicenseExpiry>
    10. <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7SerialNumber>
    11. Data>
    12. <Signature>
    13. sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=
    14. Signature>
    15. License>
    4.添加工具类代码
    1. @Slf4j
    2. public class MatchLicense {
    3. public static void init() {
    4. try {
    5. log.info("实现aspose-words授权 -> 去掉头部水印");
    6. /*
    7. 实现匹配文件授权 -> 去掉头部水印 `Evaluation Only. Created with Aspose.Words. Copyright 2003-2018 Aspose Pty Ltd.` |
    8. `Evaluation Only. Created with Aspose.Cells for Java. Copyright 2003 - 2020 Aspose Pty Ltd.`
    9. */
    10. InputStream is = new ClassPathResource("license.xml").getInputStream();
    11. License license = new License();
    12. license.setLicense(is);
    13. } catch (Exception e) {
    14. log.error("《aspose-words授权》 失败: {}", e.getMessage());
    15. }
    16. }
    17. }
    5.使用示例:在使用api前调用方法即可
    1. // 将Word文档转换为PDF
    2. ByteArrayInputStream wordInputStream = new ByteArrayInputStream(wordOutputStream.toByteArray());
    3. // 获得授权
    4. MatchLicense.init();
    5. Document doc = new Document(wordInputStream);
    6. doc.save(getOutputPath(), SaveFormat.PDF);

  • 相关阅读:
    仓库管理系统源代码集合,带图片展示和网站演示
    算法-链表-简单-相交、反转、回文、环形、合并
    通过多线程处理提高Redis性能
    每日一个设计模式之【适配器模式】
    新版原型和原型链详解,看完整个人都通透
    Java入门第三季
    从零开始 Spring Cloud 13:分布式事务
    Ubuntu安装samba服务器
    华为:手机王者归来,汽车起死回生
    【C++心愿便利店】No.12---C++之探索string底层实现
  • 原文地址:https://blog.csdn.net/weixin_55751186/article/details/139644185