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

Constants文件内容:
package com.lingxu.licenseConfig;
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;
@Slf4j
public class MatchLicense {@Autowiredprivate ResourceLoader resourceLoader;public void init() {try {log.info("实现`aspose-words`授权 -> 去掉头部水印");
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;
@Slf4j
@Component
public class StartAppRunner implements CommandLineRunner {@Overridepublic void run(String... args) throws Exception {log.info("《服务初始化执行处理》 start...");try {log.info("实现`aspose-words`授权 -> 去掉头部水印");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 JavaProduct><Product>Aspose.Words for JavaProduct>Products><EditionType>EnterpriseEditionType><SubscriptionExpiry>20991231SubscriptionExpiry><LicenseExpiry>20991231LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7SerialNumber>Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo&#43;d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU&#61;Signature>
License>