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)
上一篇 2022年7月7日 上午10:16
下一篇 2022年7月7日 上午10:16


相关推荐

  • python zipfile_Python zipfile

    python zipfile_Python zipfile从简单的角度来看的话,zip格式会是个不错的选择,而且python对zip格式的支持够简单,够好用。1)简单应用如果你仅仅是希望用python来做压缩和解压缩,那么就不用去翻文档了,这里提供一个简单的用法,让你一看就能明白。importzipfilef=zipfile.ZipFile(‘filename.zip’,’w’,zipfile.ZIP_DEFLATED)f.write(‘fil…

    2025年12月15日
    6
  • 对话

    对话

    2021年5月4日
    112
  • windows 杀进程命令[通俗易懂]

    windows 杀进程命令[通俗易懂]netstat-ano|findstr端口号例如:netstat-ano|findstr8080taskkill/pid{pid}例如:taskkill/pid{7888}

    2025年9月15日
    8
  • 防火墙之SNAT和DNAT

    防火墙之SNAT和DNAT1SNAT 原理与应用 1 1SNAT 应用环境和策略的原理 1 2SNAT 工作原理 1 3SNAT 转换前提条件 1 4 路由转发开启方式 1 5SNAT 转换 1 6 小知识扩展 2SNAT 案例 3DNAT 原理与应用 3 1DNAT 应用环境 3 2DNAT 策略原理 3 3DNAT 转换前提条件 3 4DNAT 转换 4DNAT 案例 5 1 防火墙规则的备份和还原 5 2tcpdump Linux 抓包监听网络流量命令

    2026年3月16日
    3
  • 荣耀方飞揭秘“豆包手机”AI 功能:基于 UI Agent 实现对通用场景的支持并自动执行

    荣耀方飞揭秘“豆包手机”AI 功能:基于 UI Agent 实现对通用场景的支持并自动执行

    2026年3月16日
    2
  • MongoDB(三)——图片存储

    MongoDB(三)——图片存储图片存储的两种思路和方法方法一 直接将图片的 base64 编码存在 MongoDB 数据库中 Base64 是一种用 64 个字符来表示任意二进制数据的方法 常用于在 URL Cookie 网页中传输少量二进制数据 前台绑定 input 的 change 事件 input change uploadPhoto event type file 利用 H5 中的 fileRead input change uploadPhoto event type file

    2026年3月16日
    2

发表回复

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

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