<html>
<head>
<title>打印</title>
<script language="javascript" src="jquery-1.4.4.min.js"></script>
<script language="javascript" src="jquery.jqprint-0.3.js"></script>
<style type="text/css">
body{ text-align:center;margin:0;}
.mk{width:49%;height:340px;margin:0px;border:#000 solid 0px;float:left;text-align:center;}
.bt{font-size:16px; font-weight:bold;text-align:center;}
.tab{width:100%;}
.pic{text-align:center; vertical-align:center;}
.stupic{width:100px;height:120px;}
.c1{width:60px;font-weight:bold;}
.c2{width:100px;}
.c3{}
.break-after {
page-break-after: always;
}
.break-before {
page-break-before: always;
}
</style>
<script language="javascript">
function aa(){
$("#dy").jqprint();
}
function printPreview() {
var printWindow = window.open('', '_blank');
var html = document.querySelector('#dy').innerHTML;
printWindow.document.write('<html><head><title>Print Preview</title>');
printWindow.document.write('</head><body>');
printWindow.document.write(html);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
}
function readTextFile(file, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
callback(xhr.responseText);
}
};
xhr.open("GET", file, true);
xhr.send();
}
function showdata(da,tipinfo){
var i;
var pnum=5; //每页几人
var num=da.length-1;
var tt='';
for(var i=0;i<num;i++){
var temp=da[i].split(',');
var xm=temp[0];
var sfz=temp[1];
var kh=temp[2];
var kaochang=temp[3];
var zuohao=temp[4];
var imgsrc='pics\\'+sfz+'.jpg';
var h2='<br><br>';
var b='<b>';
if((i+1) % pnum==0 && i!=0){
tt='<div class="break-after" style="page-break-after:always;">';
}else{
tt='<div>';
}
tt+='<div class=mk>'
tt+='<div class=bt>'
tt+='2010年济南市初三年级学生学业水平考试'+h2;
tt+='准 考 证'+h2;
tt+='</div>';
tt+='<table class="tab">'
tt+=' <tr>'
tt+=' <td class=c1>'
tt+=' 考号:</td>'
tt+=' <td class=c2>'
tt+=kh+' </td>'
tt+=' <td class=pic rowspan="4">'
tt+=' <img src="'+imgsrc+'" class=stupic></td>'
tt+=' </tr>'
tt+=' <tr>'
tt+=' <td class=c1>'
tt+=' 姓名:</td>'
tt+=' <td>'
tt+=xm+'</td>'
tt+=' </tr>'
tt+=' <tr>'
tt+=' <td class=c1>'
tt+=' 考场:</td>'
tt+=' <td>'
tt+=kaochang+'</td>'
tt+=' </tr>'
tt+=' <tr>'
tt+=' <td class=c1>'
tt+=' 座号:</td>'
tt+=' <td>'
tt+=zuohao+'</td>'
tt+=' </tr>'
tt+=' <tr>'
tt+=' <td colspan="2">'
tt+=tipinfo
tt+=' <td>'
tt+=' </td>'
tt+=' </tr>'
tt+='</table>'
tt+='</div>';
$("#dy").append(tt);
}
}
$(document).ready(function(){
var tipinfo='';
readTextFile("tipinfo.txt", function(text) {
tipinfo=text;
});
readTextFile("stu.txt", function(text) {
if(text.length<=0){alert('读取stu.txt文件数据错误'); return false;}
showdata(text.split('#'),tipinfo);
});
});
</script>
</head>
<body>
<div id="dy">
</div>
</body>
</html>
在线准考证打印
最新推荐文章于 2024-11-10 22:45:39 发布