13、使用aspose word转pdf的记录

13、使用aspose word转pdf的记录:

在这里插入图片描述

Constants文件内容:

package com.lingxu.licenseConfig;

/**
 * <p>
 * 全局常用变量
 * </p>
 *
 * @author zhengqing
 * @description
 * @date 2019/10/12 14:47
 */
public class Constants {

    // ===============================================================================
    // ============================ ↓↓↓↓↓↓ 文件系列 ↓↓↓↓↓↓ ============================
    // ===============================================================================

    /**
     * 系统分隔符
     */
    public static String SYSTEM_SEPARATOR = "/";

    /**
     * 获取项目根目录
     */
    public static String PROJECT_ROOT_DIRECTORY = System.getProperty("user.dir").replaceAll("\\\\", SYSTEM_SEPARATOR);

    /**
     * 临时文件相关
     */
    public final static String DEFAULT_FOLDER_TMP = PROJECT_ROOT_DIRECTORY + "/tmp";
    public final static String DEFAULT_FOLDER_TMP_GENERATE = PROJECT_ROOT_DIRECTORY + "/tmp-generate";

}

MatchLicense:文件内容:

package com.lingxu.licenseConfig;

import com.aspose.words.License;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;

import java.io.InputStream;

/**
 * <p>
 * `aspose-words`授权处理
 * </p>
 *
 * @author zhengqing
 * @description
 * @date 2020/12/30$ 11:33$
 */
@Slf4j
public class MatchLicense {
    @Autowired
    private ResourceLoader resourceLoader;

    public  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();
            Resource resource = resourceLoader.getResource("classpath:license.xml");
            InputStream is = resource.getInputStream();
            License license = new License();
            license.setLicense(is);
        } catch (Exception e) {
            log.error("《`aspose-words`授权》 失败: {}", e.getMessage());
        }
    }

}

StartAppRunner:内容

package com.lingxu.licenseConfig;

import com.aspose.words.License;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;

import java.io.InputStream;

/**
 * <p>
 * 服务初始化之后,执行方法
 * </p>
 *
 * @author zhengqing
 * @description
 * @date 2020/5/22 19:29
 */
@Slf4j
@Component
public class StartAppRunner implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        log.info("《服务初始化执行处理》 start...");
        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());
        }
        log.info("《服务初始化执行处理》 end...");
    }

}

在resource中放入license.xml文件

<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>

<!--  <Signature>Rgt4VMu3wfLGG8ZRjQ6/zGvG0NDiqDy8xd4E6H4uRgLOO6l1Q7psY5YG7ByQyv9ybUv9inqp00s6AwpzhSzMyjC1m6nCtMMyHKJ1jMNN3t7rrV08DUeBCOg9JOqc8pyJNWBiS3+gU+24+L0EG7ExpaG4J2OcHtsnpmAwOLekxwg=</Signature>-->
<!--  <Signature>0nRuwNEddXwLfXB7pw66G71MS93gW8mNzJ7vuh3Sf4VAEOBfpxtHLCotymv1PoeukxYe31K441Ivq0Pkvx1yZZG4O1KCv3Omdbs7uqzUB4xXHlOub4VsTODzDJ5MWHqlRCB1HHcGjlyT2sVGiovLt0Grvqw5+QXBuinoBY0suX0=</Signature>-->
</License>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值