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>