当前位置: 首页 > news >正文

优秀的个人网站设计国外html响应式网站模板

优秀的个人网站设计,国外html响应式网站模板,c2c的电子商务平台有哪些,长春市建设集团股份有限公司【aspose-words-22.12-jdk17.jar】word文档转pdf 前置工作1、下载依赖2、安装依赖到本地仓库 项目1、配置pom.xml2、配置许可码文件(不配置会有水印)3、工具类4、效果 踩坑1、pdf乱码2、word中带有图片转换 前置工作 1、下载依赖 通过百度网盘分享的文…

【aspose-words-22.12-jdk17.jar】word文档转pdf

  • 前置工作
    • 1、下载依赖
    • 2、安装依赖到本地仓库
  • 项目
    • 1、配置pom.xml
    • 2、配置许可码文件(不配置会有水印)
    • 3、工具类
    • 4、效果
  • 踩坑
    • 1、pdf乱码
    • 2、word中带有图片转换

前置工作

1、下载依赖

通过百度网盘分享的文件:aspose-words-22.12-jdk17.jar
链接:https://pan.baidu.com/s/137_fNgHCKSSEqcavWGehtA?pwd=2xoe
提取码:2xoe
在这里插入图片描述

2、安装依赖到本地仓库

xxxxxxxxxx = jar下载之后的目录

 mvn install:install-file -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=15.8.0 -Dpackaging=jar  -Dfile="F:\java\xxxxxxxxxx\aspose-words-15.8.0-jdk16.jar"

在这里插入图片描述

项目

1、配置pom.xml

		<!-- word转pdf  --><dependency><groupId>com.aspose</groupId><artifactId>aspose-words</artifactId><version>15.8.0</version></dependency>

2、配置许可码文件(不配置会有水印)

在resource路径下配置license.xml文件


<?xml version="1.0" encoding="UTF-8" ?>
<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>

在这里插入图片描述

3、工具类

package xxx.xxx.xx;import com.aspose.words.Document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.online.config.exception.BusinessException;import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;/*** 使用Aspose将Word转换为PDF的工具类* 注意:需要在resource路径下配置license.xml文件*/
@Slf4j
public class Word2PdfUtil {public static void main(String[] args) {String inputPath = "F:\\opt\\upFiles\\2024-07-24\\2024072411362566_1721792185072.docx";String outputPath = "C:\\Users\\123\\Desktop\\1\\667\\bbb.pdf";try {doc2pdf(inputPath, outputPath);} catch (BusinessException e) {e.printStackTrace();}}/*** 将Word文档转换为PDF** @param inPath  输入的Word文件路径* @param outPath 输出的PDF文件路径*/public static void doc2pdf(String inPath, String outPath) throws BusinessException {// 如果未获取到许可证,则抛出业务异常if (!getLicense()) {throw new BusinessException("未配置许可证!");}try (FileOutputStream os = new FileOutputStream(outPath)) {long startTime = System.currentTimeMillis();// 要转换的Word文档Document doc = new Document(inPath);// 保存为PDF格式doc.save(os, SaveFormat.PDF);log.info("PDF转换完成,耗时:{}ms,输出路径:{}", System.currentTimeMillis() - startTime, outPath);} catch (Exception e) {e.printStackTrace();}}public static ByteArrayOutputStream doc2pdfByteArrayOutputStream(InputStream inputStream)  {// 如果未获取到许可证,则抛出业务异常if (!getLicense()) {throw new JeecgBootException("未配置许可证!");}try {long startTime = System.currentTimeMillis();// 要转换的Word文档Document doc = new Document(inputStream);ByteArrayOutputStream bao = new ByteArrayOutputStream();doc.save(bao, SaveFormat.PDF);log.info("PDF转换完成,耗时:{}ms", System.currentTimeMillis() - startTime);return bao;} catch (Exception e) {e.printStackTrace();}return null;}/*** 获取Aspose的许可证* 如果未获取则转换的pdf带有水印** @return 是否成功获取许可证*/public static boolean getLicense() {boolean result = false;// license.xml文件应放在resource路径下try (InputStream is = Word2PdfUtil.class.getClassLoader().getResourceAsStream("license.xml");) {License license = new License();license.setLicense(is);result = true;} catch (Exception e) {e.printStackTrace();}return result;}}

4、效果

在这里插入图片描述

踩坑

1、pdf乱码

将win机器的c:\windows\fonts目录下的全部文件拷贝到生产服务器字体安装目录下,然后执行以下命令更新字体缓存

# 创建目录,将win机器的c:\windows\fonts目录下的全部文件拷贝到此目录下
mkdir mkdir /usr/share/fonts/win
cd /usr/share/fonts 
sudo fc-cache -fv
# 执行命令让字体生效
source /etc/profile

在这里插入图片描述

2、word中带有图片转换

word中如果有jpg格式的图片,需要转换格式成 png

http://www.yayakq.cn/news/605377/

相关文章:

  • 能不能同行网站做站长统计关于建设学校网站的报告
  • 做网站初中不买域名怎么做网站
  • 网站开发工具以及优缺点购物网站黑白
  • 济宁网站建设云科网络网站建设及维护涉及哪些内容
  • 做电影网站模板教学设计怎能建设个人网站
  • 搭建网站用服务器还是虚拟主机手机社交网站模板
  • 企业网站博客上如何推广网站引导页的作用
  • 公众平台的微信网站开发wordpress导出xml
  • 网站定制开发哪家厉害建站快车加盟
  • 信用网站建设东莞广告公司有哪些
  • 唐山市住房和城乡建设局门户网站东莞企业网站教程
  • 我是怎么做网站架构的网站备案一般多久
  • 网站怎么做本地映射做互助盘网站多少钱
  • wap建站教程.net 网站开发权限设计
  • 湖北 商城网站建设多少钱wordpress 重复插件
  • 学校网站查询学历西安企业网站建设公司
  • 做数码测评的网站小型电商网站模板
  • 做网站怎么分手机版和电脑版营销类网站如何优化
  • 郑州市住房和城乡建设厅网站山东省商务厅网站开发区管理处
  • 做塑料的外贸网站有哪些旅游网站开发报告
  • 北京智能网站建设系统加盟hugo网站建设
  • 为某网站做一则广告语网站建设制作报价
  • 广州市网站建设 合优全球网络营销公司排行榜
  • 网站建设维护是做什么的建设工程施工合同司法解释一二三
  • 网站推广的最终目的是什么wordpress菜单栏下拉
  • 免费空间网站推荐一直能打开的网站突然打不开
  • 建站快车来电受欢迎的丹阳网站建设
  • 南京本地网站建站福州企业网站制作
  • 海淀做企业网站的公司北京网站建站系统平台
  • 如何在百度开个网站湖南网站建设公司 尖端磐石网络