aspose-words去水印自用资源

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

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

1.引入依赖
    <dependencies>
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>18.6</version>
            <classifier>jdk16</classifier>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>aspose-maven-repository</id>
            <url>https://artifact.aspose.com/repo/</url>
        </repository>
    </repositories>
2.下载依赖后去依赖仓库位置删掉从官方源下载的版本

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

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

3.添加license.xml文件到src/main/resources目录下
<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>
4.添加工具类代码
@Slf4j
public class MatchLicense {

    public static void init() {
        try {
            log.info("实现aspose-words授权 -> 去掉头部水印");
            /*
              实现匹配文件授权 -> 去掉头部水印 `Evaluation Only. Created with Aspose.Words. Copyright 2003-2018 Aspose Pty Ltd.` |
                                          `Evaluation Only. Created with Aspose.Cells for Java. Copyright 2003 - 2020 Aspose Pty Ltd.`
             */
            InputStream is = new ClassPathResource("license.xml").getInputStream();
            License license = new License();
            license.setLicense(is);
        } catch (Exception e) {
            log.error("《aspose-words授权》 失败: {}", e.getMessage());
        }
    }
}
5.使用示例:在使用api前调用方法即可
        // 将Word文档转换为PDF
        ByteArrayInputStream wordInputStream = new ByteArrayInputStream(wordOutputStream.toByteArray());
        // 获得授权
        MatchLicense.init();
        Document doc = new Document(wordInputStream);
        doc.save(getOutputPath(), SaveFormat.PDF);

相关推荐

  1. aspose-words水印自用资源

    2024-06-14 17:28:03       34 阅读
  2. Aspose.Words简单介绍

    2024-06-14 17:28:03       52 阅读
  3. aspose-words字体转换

    2024-06-14 17:28:03       45 阅读
  4. Aspose-words详细功能介绍

    2024-06-14 17:28:03       61 阅读
  5. 使用aspose.Words更新表格列宽

    2024-06-14 17:28:03       49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-14 17:28:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-14 17:28:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-14 17:28:03       87 阅读
  4. Python语言-面向对象

    2024-06-14 17:28:03       96 阅读

热门阅读

  1. k8s_用CronJob控制器实现定期任务举例

    2024-06-14 17:28:03       32 阅读
  2. 【Go语言】Go语言中的接口类型

    2024-06-14 17:28:03       37 阅读
  3. 【Flutter】路由组件的应用 (学习记录)

    2024-06-14 17:28:03       30 阅读
  4. Spring Boot中使用logback出现LOG_PATH_IS_UNDEFINED文件夹

    2024-06-14 17:28:03       33 阅读
  5. 数值类型==和equals别用错

    2024-06-14 17:28:03       41 阅读
  6. Qt QMake指南(如何写pro文件)

    2024-06-14 17:28:03       84 阅读
  7. Rabbit MQ和Kafka的区别

    2024-06-14 17:28:03       30 阅读
  8. Kafka基础架构与核心概念?有哪些应用场景?

    2024-06-14 17:28:03       32 阅读
  9. Kafka之ISR机制的理解

    2024-06-14 17:28:03       29 阅读
  10. 10.GLM

    10.GLM

    2024-06-14 17:28:03      33 阅读
  11. Golang-goroutine互斥锁与读写互斥锁

    2024-06-14 17:28:03       31 阅读
  12. 多商家抽奖管理系统介绍和小程序APP演示

    2024-06-14 17:28:03       35 阅读