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;

}

}

一键复制

编辑

原始数据

按行查看

历史

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

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

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • 1.7-工控上位机软件开发平台介绍

    1.7-工控上位机软件开发平台介绍一、前言前面几章一直没有提到上位机的另一个主要使用场合,即“工业上位机软件”。主要是因为本人没有接触过,不敢贸然发表见解类的文章。最近在机缘巧合下,对“工业上位机软件”有了一些初步的了解。在这里和大家分享一下。注意本节的内容还不够专业全面,只适合对“工控软件”进行一个初步的了解。二、工业“自动化”控制系统的组成在工业生产过程中,最重要的是安全,其次是稳定。工业生产环境中可以常见大如“吊车”般的设备、有毒气体、强碱、强酸、几千度的高温、易燃易爆气体、高压水蒸气。所以容不得半点错误,出错就意味着要死人,因

    2022年5月31日
  • Homebrew新一代OS X套件管理工具 高速安装Git[通俗易懂]

    Homebrew新一代OS X套件管理工具 高速安装Git

    2022年1月31日
  • js 手机号码正则

    js 手机号码正则varphone=document.getElementById(‘phone’).value;if(!(/^1[3456789]\d{9}$/.test(phone))){alert(“手机号码有误,请重填”);returnfalse;}varphone=document.getElementById(‘phon…

    2022年6月11日
  • 算法 – 求和为n的连续正整数序列(C++)

    算法 – 求和为n的连续正整数序列(C++)

    2022年2月3日
  • deepfakes怎么用_如何使用 Deepfakes 换脸(示例代码)

    deepfakes怎么用_如何使用 Deepfakes 换脸(示例代码)如何使用Deepfakes换脸1.获取deepfakes工具包gitclonehttps://github.com/deepfakes/faceswap.git2.补齐依赖包:pipinstalltqdmpipinstallcv2pipinstallopencv-contrib-pythonpipinstalldlibpipinstallkeraspipinstall…

    2022年5月26日
  • 操作系统中并发和并行的区别在于_线程是并行还是并发

    操作系统中并发和并行的区别在于_线程是并行还是并发一、教材解释:·并行是指两个或者多个事件在同一时刻发生,而并发是指两个或者多个事件在同一时间间隔发生·并行是在不同实体上的多个事件,并发是在同一实体上的多个事件二、c语言站长公众号解释:1、并发早期计算机的CPU都是单核的,一个CPU在同一时间只能执行一个进程或线程,当系统中有多个进程或线程等待执行时,CPU只能执行完一个再执行下一个。计算机在运行过程中,有很多指令会设计i/o操作,而i/o操作又是相当耗时间的,速度远远低于CPU,这导致CPU经常处于空闲状态,只能等待i/o操作完成

    2022年11月3日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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