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

  • 相关阅读:
    HTML简介与常见标签
    【Docker】——镜像
    Centos7环境下安装MySQL8详细教程
    Chapter9.4:线性系统的状态空间分析与综合(下)
    Keil setting issue
    【力扣刷题】重新格式化电话号码
    Android 启动流程及 init 进程解析
    第一章:Class文件结构
    阿里笔试——总结2
    Java学习Day028(封装和包,关键字)
  • 原文地址:https://blog.csdn.net/weixin_55751186/article/details/139644185