java查询信息生成相关证书图片

查询信息生成证书图片

 @RequestMapping(value = "/fa/applet/certificate", method = RequestMethod.GET)
    public void imgReferer(HttpServletRequest request, HttpServletResponse response) {
        // 将图像输出到Servlet输出流中。
        ServletOutputStream sos = null;
        try {
            PageData pd = this.getPageData();

            sos = response.getOutputStream();

            HtmlImgGenerator imageGenerator = new HtmlImgGenerator();
            imageGenerator.setSize(new Dimension(800, 1127));
//            String url = new File("F:/test.html").toURI().toString();
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
            System.out.println(basePath);
            imageGenerator.loadUrl(basePath+"f/certificate?id="+pd.get("id"));
            Thread.sleep(1000);
            BufferedImage image = imageGenerator.getBufferedImage();

            BufferedImage bufferedImageToWrite = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
            bufferedImageToWrite.createGraphics().drawImage(image, 0, 0, Color.WHITE, null);

            ImageIO.write(bufferedImageToWrite, "png", sos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 证书页面
     *
     * @return
     */
    @RequestMapping(value = "/f/certificate")
    public ModelAndView certificate() {
        ModelAndView mv = this.getModelAndView();
        PageData pd = this.getPageData();
        
        PageData data=tDonationDetailsService.getDonationInfo(pd);

        StringBuffer content=new StringBuffer();
        content.append("感谢您“");
        content.append(data.getString("title"));
        content.append("”xxx");
        data.put("content",content.toString());
        data.put("time",DateUtil.getDays1());

        mv.addObject("pd",data);
        mv.setViewName("certificate");
        return mv;
    }

jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page  session="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()	+ path + "/";
%>
<!DOCTYPE html>
<html>

<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<div style="padding:15px 20px 15px 15px;width: 620px;background-color: #e35f00">
	<div style="padding:10px 10px 0 10px;background-color: white;border-radius: 25px 25px 0 0; ">
		<div style="padding:10px 10px 0 10px;border:1px dashed red;border-radius: 25px 25px 0 0; ">
			<div style="border:1px dashed red;border-radius:  25px 25px 0 0;">
				<div style="padding-left: 50px;padding-right: 50px;">
					<div style="text-align: center;padding-top: 50px;font-size: 70px;color:#e35f00;font-weight: bold ">xx证书</div>
					<div style="text-align: center;padding-top: 10px;font-size:20px; ">编号:${pd.certificate_no}</div>
					<div style="text-align: center;padding-top: 50px;padding-bottom: 20px;font-size: 36px; ">${pd.nickName}</div>
					<hr style="border: 1px dashed #e35f00;"></hr>
					<div style="min-height:250px;text-indent: 50px;font-size: 27px;letter-spacing: 2px;line-height: 50px;padding-top: 20px">
						${pd.content}
					</div>
				</div>
				<div style="height:200px;padding-left: 50px;padding-right: 50px;text-align: center;background: url(assets/img/zhang.png) no-repeat center center;">
					<div style="text-align: center;padding-top: 50px;font-size: 27px; ">滨州市慈善总会</div>
					<div style="text-align: center;padding-top: 10px;font-size: 27px; ">${pd.time}</div>
					<!--                    <img src="zhang.png" style="margin-top: -161px">-->
				</div>
			</div>
		</div>
	</div>
	<div style="height: 150px;">

	</div>
</div>

</body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值