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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • smartctl命令详解_fuser命令

    smartctl命令详解_fuser命令smart用法1.smartctl-son/dev/sda”开启磁盘的smart功能2.smartctl-a/dev/sda”显示磁盘的详细smart信息3.smartctl–test=short/dev/sda4.smartctl–test=short/dev/sdb检查磁盘坏道…

    2022年10月8日
    7
  • <Javascript>浅谈js“三元表达式” (三元运算符)

    <Javascript>浅谈js“三元表达式” (三元运算符)前言各位大神,大家好,相约周三。我们又见面了。众所周知,三元表达式在代码量上比if…else语句更简洁一些。但是博主刘少在可读性上更加偏向于if…else语句。三元表达式不仅在js中使用,在很多后台程序语言,比如java、php中都有使用,不过在js中对于三元表达式的要求貌似要松很多。废话不多说。下面一起看看三元表达式。三元表达式素质N连问首先为什么叫三元表达式?顾…

    2022年7月15日
    14
  • kettle工具使用及集成[通俗易懂]

    kettle工具使用及集成[通俗易懂]kettle简介Kettle是一款免费开源的基于Java的企业级ETL工具,功能强大简单易用,无可抗拒。

    2022年10月9日
    3
  • webpack(2)webpack核心概念「建议收藏」

    webpack(2)webpack核心概念「建议收藏」前言本质上,webpack是一个用于现代JavaScript应用程序的静态模块打包工具。当webpack处理应用程序时,它会在内部构建一个依赖图(dependencygraph),此

    2022年8月7日
    7
  • wincc远程服务器配置,WINCC-OPC服务器配置

    wincc远程服务器配置,WINCC-OPC服务器配置《WINCC-OPC服务器配置》由会员分享,可在线阅读,更多相关《WINCC-OPC服务器配置(13页珍藏版)》请在人人文库网上搜索。1、两台WinCC之间OPC通讯方法(WinXP)OPC客户端1、登陆计算机名及密码要与服务器端(OPCServer)一致。a)如:用户名:administrator密码:12342、OPC客户端要与服务器端处于同一个网络。a)如:OPCServerIP:…

    2022年6月20日
    33
  • emWin 介绍_emwin教程

    emWin 介绍_emwin教程一、emWin介绍emWin是Segger公司针对嵌入式平台开发的稳定、高效的图形软件库,适合用于任何图形LCD的操作应用,并可输出高质量的无锯齿的文字和图形,通过调用emWin提供的函数接口,开发嵌入式图形界面应用变得简单而快捷。二、emwWn、ucGUI、STemWin三者之间的关系1.三者都是Segger公司的产品。2.emwWn是Segger公司图形系统的正式统称。3.uc…

    2022年10月14日
    3

发表回复

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

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