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


相关推荐

  • webstorm必装十大插件_webpack常用插件

    webstorm必装十大插件_webpack常用插件activate-power-mode狂拽炫酷吊炸天装逼的插件,atom上的神器啊,抱着试一试的心态一搜,webstorm上居然也有了,安装之后可以在window->activate-power-mode中关闭震动以及开启彩色模式。TabNine可以记录用户习惯自动补全代码,牛逼ESLint代码检查插件RainbowBrackets彩虹色的括号,颜……

    2022年9月9日
    2
  • C/C++指针参数赋值问题

    C/C++指针参数赋值问题

    2021年11月20日
    41
  • OpenProcessToken令牌函数使用方法

    OpenProcessToken令牌函数使用方法转载自:https://www.cnblogs.com/mengfanrong/p/5185850.html GetCurrentProcessID得到当前进程的IDOpenProcessToken得到进程的令牌句柄LookupPrivilegeValue查询进程的权限AdjustTokenPrivileges调整令牌权限要对一个随意进程(包括系统安全进程和服务进程)进行指定…

    2022年6月25日
    22
  • 将oracle端口1521共享_[转载]Oracle 1521端口不通 telnet不通

    将oracle端口1521共享_[转载]Oracle 1521端口不通 telnet不通今天启动工程,突然提示无法连接远程Oracle。我试着telnetOracle服务器1521端口,提示连接失败。D:DocumentsandSettingsAdministrator>telnet10.201.70.681521正在连接到10.201.70.68…不能打开到主机的连接,在端口1521:连接失败Oracle服务器与本机都在局域网内,不存在网络不通问题,怎么会…

    2022年5月1日
    99
  • 网页406错误(网页错误代码1607)

    原因出现网页出现406问一般为一下两种情况 *1、缺失jar包, * *2、如果访问的url的后缀名是以.html结尾的,则服务端不能响应json数据。因为springMVC会误以为.html后缀名的请求,是请求访问某个html文件,则springMVC则无法处理响应json数据 解决方法 *解决方法: * 1、检查所依赖的jar包是否完整 *2、在we…

    2022年4月17日
    59
  • 学习Spark的入门教程——《Spark大数据实例开发教程》

    学习Spark的入门教程——《Spark大数据实例开发教程》去年年底出的一本学习Spark大数据的教程,文笔上言简意赅,只讲最常用的内容,很适合入门学习。是面向Spark开发者的一本实用参考书,结合实例全面系统的介绍了Spark工具的开发与使用。全书包括五章内容,第一章介绍Spark生态圈以及SparkRDD的编程模型等内容;第二章介绍SparkRDD实战案例与解析,包含Spark应用程序的部署、Spark的各种应用案例与解析、…

    2022年5月2日
    23

发表回复

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

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