/**
* 保存下载图片
*
* @author zyl<br/>
* 2011-2-9 下午06:11:01<br/>
* version 1.0<br/>
*/
public class PrintImageAction extends WWAction {
private String downfileName;
private String html;
private String imagename;
public String printImage() {
String filename = "";
String url="";
if ("2".equals(EopSetting.RUNMODE)) {
EopSite site = EopContext.getContext().getCurrentSite();
filename = "/user/" + site.getUserid() + "/" + site.getId()
+ "/printimage";
} else {
filename = "/printimage";
}
filename = filename + "/printimage"
+ com.enation.framework.util.DateUtil.getDateline() + ".jpg";
File file = new File(EopSetting.IMG_SERVER_PATH + filename);
if (!file.exists())
file.mkdirs();
url = EopSetting.IMG_SERVER_PATH
+ com.enation.framework.util.DateUtil.getDateline() + ".html";
String filepath = EopSetting.IMG_SERVER_DOMAIN + filename;
try {
new HtmlToJpgUtil(file,url,html);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(EopSetting.IMG_SERVER_DOMAIN + filename);
this.json="{'result':0,'message':'"+"statics"+filename+"'}";
return this.JSON_MESSAGE;
}
public InputStream getTargetFile() throws Exception
{
downfileName = "myadmission.jpg";
return ServletActionContext.getServletContext().getResourceAsStream(imagename);
}
public String execute() throws Exception {
return "success";
}
public String getDownfileName() {
return downfileName;
}
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
public String getImagename() {
return imagename;
}
public void setImagename(String imagename) {
this.imagename = imagename;
}
}
<action name="printImage" class="printImageAction">
<result name="success" type="stream">
<!--默认为 text/plain-->
<param name="contentType">image/jpg</param>
<param name="inputName">targetFile</param>
<param name="contentDisposition">attachment;filename="${downfileName}"</param>
<!-- 输出时缓冲区的大小 -->
<param name="bufferSize">4096</param>
</result>
</action>
<script type="text/javascript" src="js/jquery.pager.js"></script>
<link href="${staticserver}/css/Pager.css" rel="stylesheet" type="text/css" />
<script src="${staticserver}/js/common/jquery.validate.js" type="text/javascript"></script>
<link href="${staticserver}/js/common/validate/validate.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="all" href="css/ui.datepicker.css" title="win2k-cold-1" />
<style>
ol li{border:0; line-height:180%;}
.tableborder{border-spacing: 1px; text-align:center;}
h3{margin:0 auto; text-align:center;}
</style>
<style type="text/css" media="print">
.noprint{ display : none }
.table1{border-collapse:collapse;}
.table1 td{border:1px solid #000;}
</style>
<div class="PassportWrap">
<form action="member_notice.html" method="post" class="validate signform">
<div class="RegisterWrap">
<!--<div class="lc noprint">
<ul class="step">
<li class="meter"><span id="regInfo" class="Infocurrent"></span>
<p>
注册</p>
</li>
<li class="meter"><span id="moreInfo" class="Infocurrent"></span>
<p>基本信息</p>
</li>
<li class="meter"><span id="sign" class="Infocurrent"></span>
<p>
报名</p>
</li>
<li class="meter"><span id="print" class="Infocurrent"></span>
<p>
打印准考证</p>
</li>
<li class="meter"><span id="checkscore" ></span>
<p>
成绩查询</p>
</li>
<li class="meter"><span id="deter_apply" ></span>
<p>
资格申请</p>
</li>
<li class="meter"><span id="jiuxjiaoyu" ></span>
<p>
继续教育</p>
</li>
</ul>
</div>-->
<div class="title" style="margin:0 auto;">
<div class="title1 noprint">打印准考证 </div>
</div>
<#if isbaoming==0>
<div id="infotip" class="clearfix" style="margin-top:80px;">
<div class="span-1 pic"></div>
<div class="span-10" style="text-align:center;width:80%;padding-left:50px;">
<!--<h4 style="color:#ff6600">温馨提示:</h4> -->
<span style="font-size:14px;line-height:280%;color:#000000;"> 打印准考证失败!您还没有报名 ,现在去 <a
href="member_registrationbefore.html" style="color:red" target="_blank">报名</a> !</span>
</div>
<#else><#if isfkc==1>
<div id="infotip" class="clearfix" style="margin-top:80px;">
<div class="span-1 pic"></div>
<div class="span-10" style="text-align:center;width:80%;padding-left:50px;">
<!--<h4 style="color:#ff6600">温馨提示:</h4>-->
<span style="font-size:14px;line-height:280%;color:#000000;">打印准考证失败!您还没有分配考场,请耐心等待通知!</span>
</div>
<#else>
<#if printadmission??>
<div style="height:50px;text-align:left;margin-top:5px;margin-left:10px;" class="noprint">
<input name="button" type="button" value=" 打 印 " class="submitBtn" id="btn_print"/>
<input name="button" type="button" value=" 保存图片 " class="submitBtn" id="btn_print_image"/>
</div>
<div id="print_image" style="width:670px; line-height:180%;margin:0 auto;font-size:12px;margin-left:10px;">
<table width="90%" border="0" cellpadding="20" cellspacing="0" style="border:1px solid #333333; padding:20px;">
<tr>
<td><h3 style="height:55px; line-height:35px;font-size:25px;font-weight:bolder;text-align:center;"><@dateFormat date="${starttimes}" pattern="yyyy"/>年统计从业资格考试准考证 </h3>
<#list printadmission as admission>
<table>
<tr>
<td><div style="float: left; width: 350px;margin-left:15px;">
<table>
<tr><td style="line-height: 260%; padding-left: 40px; color: #000000; font-size: 14px;"><strong>姓 名:</strong>${admission.name}<br /> <strong>身份证号:</strong>${admission.identity}<br />
<strong>准考证号:</strong>${admission.admission_id}<br /> <strong>考试地点:</strong><#if
admission.school_name??>${admission.school_name}<#else>暂无</#if>
<br /> <strong>考试地址:</strong><#if
admission.school_address??>${admission.school_address}<#else>暂无</#if></td></tr>
</table>
</div>
</td>
<td>
<div style="width: 139px; float: right; margin-right: 32px; _margin-right: 16px; ">
<img id="pic"
src="<@GoodsPic pic='${admission.photo_file}' postfix=''/>"
>
</div>
</td>
</tr>
</table> </#list>
<div align="center" style="clear: both;">
<h3 style="margin-top: 10px; font-size: 20px;">考试安排</h3>
<table cellpadding="2" width="95%" cellspacing="1"
bgcolor="#000000" class="table1">
<tr>
<td width="238" height="30" align="center" bgcolor="#FFFFFF"
style="padding-top: 5px; padding-top: 9px\0; _padding-top: 9px; color: #000000;"><strong>考试时间
</strong>
</td>
<td width="192" align="center" bgcolor="#FFFFFF"
style="padding-top: 5px; padding-top: 9px\0; _padding-top: 9px; color: #000000;"><strong>考试科目
</strong>
</td>
<td width="70" align="center" bgcolor="#FFFFFF"
style="padding-top: 5px; padding-top: 9px\0; _padding-top: 9px; color: #000000;"><strong>考场号
</strong>
</td>
<td width="70" align="center" bgcolor="#FFFFFF"
style="padding-top: 5px; padding-top: 9px\0; _padding-top: 9px; color: #000000;"><strong>座位号
</strong>
</td>
</tr>
<#list scoreList as score>
<tr>
<td width="238" align="center" height="25" bgcolor="#FFFFFF"
style="color: #000000; padding-top: 3px; padding-top: 5px\0; _padding-top: 3px; color: #000000;""><@dateFormat
date="${score.starttime?c}" pattern="yyyy年MM月dd日"/><#if
(score.start_hours<10)>0${score.start_hours}<#else>${score.start_hours}</#if>点<#if
(score.start_minite<10)>0${score.start_minite}<#else>${score.start_minite}</#if>分-<#if
(score.end_hours<10)>0${score.end_hours}<#else>${score.end_hours}</#if>点<#if
(score.end_minite<10)>0${score.end_minite}<#else>${score.end_minite}</#if>分</td>
<td width="192" align="center" bgcolor="#FFFFFF"
style="color: #000000; padding-top: 3px; padding-top: 5px\0; _padding-top: 3px; color: #000000;">${score.subject_name}</td>
<td width="70" align="center" bgcolor="#FFFFFF"
style="color: #000000; padding-top: 3px; padding-top: 5px\0; _padding-top: 3px; color: #000000;"><#if
score.classroom_name??
>${score.classroom_name}<#else>暂无</#if></td>
<td width="70" align="center" bgcolor="#FFFFFF"
style="color: #000000; padding-top: 3px; padding-top: 5px\0; _padding-top: 3px; color: #000000;"><#if
score.seat_id lt
10>0${score.seat_id}<#else>${score.seat_id}</#if></td>
</tr>
</#list>
</table>
</div>
<p style="color: #ff0000; width: 90%; margin: 0 auto;">
注:准考证上没有照片信息或照片信息不清晰的考生,务必在参加考试时携带本人近期二寸正面免冠照片一张交给本考场的监考员。</p>
<h3 style="margin-top: 10px; font-size: 20px; text-align:center;" >考生注意事项</h3>
<p><ol style="width: 90%; margin: 0 auto; padding-left: 3px;">
<li>“准考证”由考生使用A4复印纸在规定时间内上网自行打印。“准考证”涂改无效,背面必须为空白。</li>
<li>考生凭“准考证”、有效身份证件(与报名时一致),按规定时间进入考场,对号入座。入座后将上述证件放在桌面左上角,以便检查。</li>
<li>应试时,考生须携带黑色或蓝色字迹钢笔或签字笔(同一科目答卷的字迹必须是一种颜色)、铅笔(2B)、橡皮。</li>
<li>严禁将各种电子设备、通讯、计算、储存或其他设备带至座位。</li>
<li>考试时间以北京时间为准。开考15分钟后不得入场。交卷出场时间不得早于各科目考试结束前30分钟。交卷出场后不得再进场续考,也不得在考场附近逗留或交谈。
</li>
<li>严禁将答题纸(卡)、试卷、草稿纸带离考场。</li>
<li>考生要严格遵守考试规则,若有作*弊行为,将取消考试资格。</li>
<li>请考生按照准考证上的指定考试地址,提前确认考点的具体位置和乘车路线。</li>
</ol>
</p>
<h3 style="margin-top: 10px; font-size: 20px;text-align:center;">诚信考试 从我做起</h3>
<p
style="width: 90%; margin: 0 auto; margin-bottom: 10px; color: #000000;">
该考生在报名确认及下载打印准考证时均已承诺“本人已周知考场规则和报考者违纪违规处理有关规定;考试当天,保证遵守考场规则;若有违反,愿按相关规定接受处理。”
</p>
</td>
</tr>
</table>
</div>
<div align="right" class="noprint" style="width:600px; line-height:180%;margin:0 auto;font-size:12px;margin-left:10px;">请用A4纸打印 </div>
<script type="text/javascript">
$(function(){
$("#pic").attr("width",137).attr("height",192);
$("#btn_print").click(function(){window.print();});
$("#btn_print_image").click(function(){
var html = "<html>"+$("#print_image").html()+"</html>";
$.ajax({
type : "post",
url : "shop/printImage!printImage.do",
data : "html=" + encodeURI(html.replace(new RegExp("tbody", 'g'), "div")) + "&rdm=" + (new Date).getTime(),
dataType : "json",
success : function(result) {
$("input[name='imagename']").attr("value",result.message);
//window.open(result.message,'_self');
$("#printImageForm").submit();
/* $("#printImageForm").ajaxSubmit({
// dataType:'json',
type : "post",
data:"imagename=" + result.message)
}); */
}
})
});
});
</script>
<#else>
<div id="infotip" class="note clearfix">
<div class="span-1 pic"></div>
<div class="span-10">
<h4>温馨提示:</h4>
打印准考证失败!考场信息有误
</div>
</#if>
</#if>
</#if>
</div>
</form>
<div style="display: none;">
<form id="printImageForm" action="shop/printImage.do">
<input name="imagename" type="text" value=""/>
</form></div>
</div>