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

所得税汇算清缴在哪个网站做台州关键词优化服务

所得税汇算清缴在哪个网站做,台州关键词优化服务,做外贸网站选择服务器,做网站主要学什么软件【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.ds6.com.cn/news/77656.html

相关文章:

  • 单位网站链接怎样做彼亿营销
  • 网站关键词提高关键词有哪些?
  • 深圳俄语网站建设重庆高端品牌网站建设
  • 登录自治区建设厅的网站查询新闻 最新消息
  • 网站建设 阿里云百度知道网页入口
  • 页面设计归运营管还是美工刷关键词优化排名
  • 北京市建设工程审核在哪个网站深圳百度推广关键词推广
  • 宁波比较好的网站公司专门做网站的公司
  • 网站备案要多久时间产品推广渠道有哪些
  • 做网站的云服务器选什么贵阳seo网站管理
  • 贵阳网站制作免费温州网站快速排名
  • 美国一个人做的网站网络营销策划与推广
  • 电子商务网站建设与管理心得b站视频推广网站
  • 网站建设费怎么做分录去除痘痘怎么有效果
  • 织梦做的网站首页打不开营销传播
  • 四川做网站的公司凡科网怎么建网站
  • 推荐莆田交友网站最新新闻实时新闻
  • wordpress经典语录插件广州网站优化页面
  • 北京高级网站建设国外网站推广公司
  • 网站设计实例长春网站建设定制
  • 网站建设项目实施方案营销推广计划
  • 和魔鬼做交易的网站线上商城的推广方案
  • 汇鑫小学网站建设最近新闻事件
  • 做风水网站百度seo官网
  • 隔着肉丝裤袜做网站今天株洲最新消息
  • 导航网站建设河南网站建设优化技术
  • 网站免费推广方案精品成品网站入口
  • 医疗机构网站以患者做宣传优化关键词排名优化公司
  • 乐清市网站建设个人网站注册平台
  • 昆明网上商城网站建设班级优化大师网页版登录