热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

13、使用asposeword转pdf的记录

13、使用asposeword转pdf的记录:Constants文件内容:packagecom.lingxu.licenseConfig;***
13、使用aspose word转pdf的记录:

在这里插入图片描述

Constants文件内容:

package com.lingxu.licenseConfig;/***

* 全局常用变量*

** @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;/***

* `aspose-words`授权处理*

** @author zhengqing* @description* @date 2020/12/30$ 11:33$*/
@Slf4j
public class MatchLicense {@Autowiredprivate 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;/***

* 服务初始化之后,执行方法*

** @author zhengqing* @description* @date 2020/5/22 19:29*/
@Slf4j
@Component
public class StartAppRunner implements CommandLineRunner {@Overridepublic 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 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>


推荐阅读
author-avatar
Peter-周周周成德
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有