java hd seks_jodconverter-web/src/main/java/cn/keking/service/impl/AseKsReportServiceImpl.java · mes…

java hd seks_jodconverter-web/src/main/java/cn/keking/service/impl/AseKsReportServiceImpl.java · mes…packagecn.keking.service.impl;importcn.keking.hutool.StrUtil;importcn.keking.render.AseKsTableRenderPolicy;importcn.keking.render.CustomReplaceOptionalTextPictureRefRenderPolicy;importcn.keking.s…

大家好,又见面了,我是你们的朋友全栈君。

package cn.keking.service.impl;

import cn.keking.hutool.StrUtil;

import cn.keking.render.AseKsTableRenderPolicy;

import cn.keking.render.CustomReplaceOptionalTextPictureRefRenderPolicy;

import cn.keking.service.CapsReportService;

import cn.keking.utils.FileUtils;

import cn.keking.utils.OfficeToPdf;

import com.deepoove.poi.XWPFTemplate;

import com.deepoove.poi.config.Configure;

import org.apache.poi.xwpf.usermodel.XWPFDocument;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.math.BigDecimal;

import java.util.Map;

/**

* @program: filepreview

* @description: Caps AseKs报告

* @author: syngna

* @create: 2020-04-14 12:08

*/

@Service(“aseKs”)

public class AseKsReportServiceImpl implements CapsReportService {

@Autowired

private OfficeToPdf officeToPdf;

private static final Logger LOGGER = LoggerFactory.getLogger(AseKsReportServiceImpl.class);

@Override

public String processCapsReport(Map data, String picturePath, String templatePath, String outputPath) {

FileOutputStream out = null;

XWPFTemplate template = null;

String errorMsg = “”;

try {

// 计算图片比例

BufferedImage image = ImageIO.read(new FileInputStream(picturePath));

int width = image.getWidth();

int height = image.getHeight();

Configure configure = Configure.newBuilder()

.bind(“dynamic_table”, new AseKsTableRenderPolicy())

.referencePolicy(

new CustomReplaceOptionalTextPictureRefRenderPolicy(“picture-right”,

new FileInputStream(picturePath),

XWPFDocument.PICTURE_TYPE_PNG, BigDecimal.valueOf(width).divide(BigDecimal.valueOf(height), 6, BigDecimal.ROUND_HALF_UP)))

.build();

template = XWPFTemplate.compile(templatePath, configure).render(data);

FileUtils.createDirPath(outputPath.substring(0, outputPath.lastIndexOf(File.separator)));

out = new FileOutputStream(outputPath);

template.write(out);

officeToPdf.doc2PDF(outputPath, outputPath.substring(0, outputPath.lastIndexOf(“.”) + 1) + “pdf”);

} catch (Exception e) {

LOGGER.error(“”, e);

errorMsg += e.getMessage();

} finally {

try {

if (out != null) {

out.flush();

out.close();

}

if (template != null) {

template.close();

}

} catch (IOException e) {

LOGGER.error(“”, e);

}

}

return errorMsg;

}

}

一键复制

编辑

原始数据

按行查看

历史

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/156404.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 专业函数绘图软件Origin

    专业函数绘图软件Origin首先:Origin软件已经是科研院所等单位的必备工作软件之一,之所以大家讨论得较少,有可能并不是其上手难度低,而是这些使用人群的学习理解能力要相对高一点吧;其次:Excel不垃圾,但在函数绘图方面,比起Origin差远了,用垃圾来形容并不过分,可以问问任何高校老师,他们还会使用Excel出图么?那简直是自己找死。当然Origin也只是在绘图方面比Excel厉害,其它的方面还是比Excel差

  • python谷歌浏览器驱动安装失败_selenium和谷歌浏览器驱动安装

    python谷歌浏览器驱动安装失败_selenium和谷歌浏览器驱动安装selenium安装:第一步:打开cmd,切换到pip工具所在目录输入指令安装:1.默认安装最新版本selenium:pip.exeinstall-uselenium2.安装指定版本pip.exeinstall”selenium==3.9.0″3.卸载指令pip.exeuninstall”selenium”第二步:安装好之后,检…

  • nessus8.15激活成功教程_etc怎么看激活成功了没有

    nessus8.15激活成功教程_etc怎么看激活成功了没有0x01下载NESSUS官网https://www.tenable.com/downloads/nessus离线插件all:https://plugins.nessus.org/offline

  • 2021,2020,2019,2018年河南高考一分一段表 (含文科和理科成绩排名) excel格式

    2021,2020,2019,2018年河南高考一分一段表 (含文科和理科成绩排名) excel格式河南省高招办的资料如下,但是是pdf格式的:2018理科排名2018文科排名博主为了生计,整理了excel档的,如果有需要,向二维码支付2元,备注邮箱地址,第一时间发送给你。…

  • 简单粗暴理解支持向量机(SVM)及其MATLAB实例

    简单粗暴理解支持向量机(SVM)及其MATLAB实例目录SVM概述SVM的改进:解决回归拟合问题的SVR多分类的SVMQP求解SVM的MATLAB实现:Libsvm【实例】用SVM分类【实例】用SVM回归SVM概述SVM已经是非常流行、大家都有所耳闻的技术了。网络上也有很多相关的博客,讲解得都非常详细。如果你要从零开始推导一个SVM,细致抠它全程的数学原理,我建议可以阅读此篇文章:ZhangHao的《从零构建支…

  • linux下vsftpd架设ftp服务器「建议收藏」

    linux下vsftpd架设ftp服务器「建议收藏」1.sudoapt-getinstallvsftpd2.使用netstat-tnl可以查看是否打开了21端口。是否有这行:tcp000.0.0.0:210.0.0.0:*LISTEN3.用浏览器访问一下吧ftp://10.45.7.25安装完毕后,匿名用户可以正常访问ftp具体配置参见:原文地址:http://…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号