使用Lodop打印:

一、在官网下载http://www.lodop.net/download.html

若是安装还是提示未安装,就按转这个

二、准备两个js

三、需要在页面最上面加入

<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<object id="LODOP_OB"
classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width= height=>
<embed id="LODOP_EM" type="application/x-print-lodop" width= height=
pluginspage="install_lodop64.exe"></embed>
</object>
<meta charset="utf-8">

引入js

四、页面源码

<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<object id="LODOP_OB"
classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width= height=>
<embed id="LODOP_EM" type="application/x-print-lodop" width= height=
pluginspage="install_lodop64.exe"></embed>
</object>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet" />
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet" />
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/Lodop/LodopFuncs.js}"></script>
<script th:src="@{/js/Mtils.js}"></script> <body class="white-bg">
<div class="btn-group-sm hidden-xs" style="margin-left: 20px" id="toolbar" role="group">
<a class="btn btn-success" onclick="PreviewMytable()" >
<i class="fa fa-plus"></i> 打印
</a>
</div>
<div id="t1">
<table class="layui-table" border="" cellpadding="" cellspacing="" align="center" style="width: 700px; height:900px; cellspacing: 0;cellpadding:0">
<tr>
<th colspan="" style="text-align: center">试卷分析报告</th>
</tr>
<tr>
<th colspan="" style="text-align: center">[[${word.year}]]学年第[[${word.eduYear}==null?:${word.eduYear}]]学期</th>
</tr>
<tr>
<th style="text-align: center" colspan="">课程名称:[[${word.lable}]]</th>
<th style="text-align: center" colspan="">班级:[[${word.deptName}]]</th>
<th style="text-align: center" colspan="">人数:[[${word.total}==null?:${word.total}]]</th>
<th style="text-align: center" colspan="">日期:[[${word.time}]]</th>
</tr> <tr style="text-align: center">
<td rowspan="" colspan="">试卷成绩</td>
<td style="text-align: center">成绩等级</td>
<td style="text-align: center">-</td>
<td style="text-align: center">-</td>
<td style="text-align: center">-</td>
<td style="text-align: center">-</td>
<td style="text-align: center"><</td>
</tr>
<tr>
<td style="text-align: center"></td>
<td style="text-align: center">(优秀)</td>
<td style="text-align: center">(良好)</td>
<td style="text-align: center">(中等)</td>
<td style="text-align: center">(及格)</td>
<td style="text-align: center">(不及格)</td>
</tr>
<tr>
<td style="text-align: center">人数</td>
<td style="text-align: center">[[${word.best}==null?:${word.best}]]人</td>
<td style="text-align: center">[[${word.good}==null?:${word.good}]]人</td>
<td style="text-align: center">[[${word.medium}==null?:${word.medium}]]人</td>
<td style="text-align: center">[[${word.pass}==null?:${word.pass}]]人</td>
<td style="text-align: center">[[${word.fail}==null?:${word.fail}]]人</td>
</tr>
<tr>
<td style="text-align: center">所占比例</td>
<td style="text-align: center">[[${word.bestRate}]]%</td>
<td style="text-align: center">[[${word.goodRate}]]%</td>
<td style="text-align: center">[[${word.mediumRate}]]%</td>
<td style="text-align: center">[[${word.passRate}]]%</td>
<td style="text-align: center">[[${word.failRate}]]%</td>
</tr>
<tr>
<td style="text-align: center" colspan="">平均成绩</td>
<td style="text-align: center" colspan="">[[${word.average}]]</td>
</tr>
<tr style=" height:200px;text-align: center">
<td>试卷情况分析</td>
<td colspan=""></td>
</tr>
<tr style=" height:200px;text-align: center">
<td >改进措施</td>
<td colspan=""></td>
</tr>
<tr>
<td>教研室主任(签字):</td>
<td colspan=""></td>
<td>系(部)主任(签字):</td>
<td colspan=""></td>
</tr>
</table>
</div>
</div> <div id="test1">
<template>
<Table stripe :columns="columns1" :data="data1"></Table>
</template>
</div> <script type="text/javascript"> var LODOP; //声明为全局变量
function PreviewMytable() { var supplier = $("#supplierSpName").val();
var pcBillnr = $("#pcBillnr").val();
var creat = $("#creat").val();
var listSize = $("#listSize").val();
var rowHeight= (listSize * 7.0)+34.0;
var rowHeight1= (listSize * 7.0)+40.0;
var endWidth = (listSize * 7.0)+50.0; // if (LODOP.webskt && LODOP.webskt.readyState == 1) { LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM')); LODOP.PRINT_INITA("-0.79mm","-3.7mm","210mm","220mm","试卷成绩分析");
//LODOP.PRINT_INITA(-3,-14,800,rowHeight,"进货单打印");
//设置纸张大小和格式
//LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4");
/*
LODOP.SET_PRINT_PAGESIZE(1,"220mm",endWidth+"mm","");
LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
LODOP.SET_PRINT_STYLEA(0,"ItemType",3);
var strStyle="<style> .z1{font-size:13px}.z2{font-size:12px}td,th {border-width: 1px;border-style: solid;border-collapse: collapse}.wk{border-bottom:1px solid #fff;border-left: 1px solid #fff;border-right: 1px solid #fff;} </style>"
//打印单抬头部分
*/ /*
LODOP.SET_PRINT_STYLEA(0,"FontSize",15); LODOP.SET_PRINT_STYLEA(0,"Bold",1); LODOP.SET_PRINT_STYLEA(0,"Alignment",3);*/
//引入打印内容
LODOP.ADD_PRINT_HTM("20.6mm","13.8mm","90%","100%",document.getElementById("t1").innerHTML);
LODOP.NewPage(); //LODOP.ADD_PRINT_IMAGE(113,564,184,312,"<img border='0' src='vm.uploadList[0].imgUrl'width='100%' height='250'/>");
//LODOP.ADD_PRINT_IMAGE(113,564,184,312,"<img border='0' src='vm.uploadListe[0].imgUrl'width='100%' height='250'/>");
//LODOP.ADD_PRINT_HTM("20.6mm","13.8mm","90%","100%",document.getElementById("test1").innerHTML);
/*
LODOP.ADD_PRINT_IMAGE(39,210,400,400,"<img border='0' src='https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87&step_word=&hs=0&pn=2&spn=0&di=147290&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=2&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=-1&cs=2432587304%2C4134874795&os=3863472431%2C2265441716&simid=3485710891%2C47672788&adpicid=0&lpn=0&ln=1582&fr=&fmq=1543374993775_R&fm=detail&ic=0&s=undefined&hd=0&latest=0&copyright=0&se=&sme=&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=http%3A%2F%2Fphotocdn.sohu.com%2F20150908%2Fmp31043208_1441704680666_3.png&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Bf5i7_z%26e3Bv54AzdH3FwAzdH3Fn8a9ndab_d808ac&gsm=0&rpstart=0&rpnum=0&islist=&querylist=&selected_tags=0' />");
*/
//LODOP.ADD_PRINT_IMAGE(113,564,184,312,"<img border='0' src='http://43.226.38.125:8080/health/files/20161221100807932_20679.png'width='100%' height='250'/>"); //LODOP.ADD_PRINT_SETUP_BKIMG("data:image/jpg;base64, /9j/4AAQSkZJRgABAgIAAAAAAAD//gAeQUNEIFN5c3RlbXMgRGlnaXRhbCBJbWFnaW5nAP/AABEIAEIAYwMBIgACEQEDEQH/2wCEABQNDxEPDBQREBEWFRQXHjIgHhsbHj0rLiQySD9MS0c/RkRQWnNhUFVsVkRGZIhlbHZ6gIKATWCNl4x9lnN+gHsBHyEhLSctWDAwWLl7aXu5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5uf/EAHkAAQADAQEBAAAAAAAAAAAAAAADBAUCAQYQAAICAgAFAgQDBwUAAAAAAAECAAMEEQUSIUFREzEiYXGBFDJCBiORobHB0VNykuHwAQEBAQEAAAAAAAAAAAAAAAAAAgEDEQEBAQEBAAMAAAAAAAAAAAAAARECURIxQf/aAAwDAQACEQMRAD8A+yiIgInk4stCnQ+JvAgdyNr0H5dsflIbXA+K5wo7Azmu2qwlUYEjrrWjqB22RZ2RR9TImzLl/Sh+xnVhAEo5FoEC0vE9H46v+JlmnMotOg+m8N0mGOaw9JMMZiOsDeiZFGRdikBtvX4PuPpNSq1Lqw9bBlPeB1ERA9iJTycglvSrP+4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jUyuERrn9lG9e\nZnF2tcs56k7b6yXMt5itCnovVvr2kI6S+YmvXOh0kDHrJGBY6A3L2DwPLyiGKciHu3SVbjJFClHs\ncIilmPYCfQcJ4NzMLL+oHYew/wAzSwODUYifEec9x7CaQAA0AAB2nO9eKwA0AANARESWsjjnDrrS\nMvDIF6jTIfZx/kTFTihqBXIRqbAO46b+s+ylPM4bj5Y+NdN5ExUz6rIpyj6QFbhlA10O5Dk5bkEG\nc5n7L2oS+HZyt5Q6mRdjcbxX1cllqeQm4lbefEt1pJMh/EcnXpvsJC5y2OjVdvwKyP7T2rhnEcht\nVYd5B7ldD+cvHPXVR2CxOyfcy9gcOvzrNVp8I92PsJocJ/ZmxCLM5wB/pod/xM+lqrSqsJWgVR7A\nCbevGYo4HB8bEAYqLLB+ojoPoJoT2JCiIiB5ERAREQEREBERAREQEREBERAREQP/2Q==\n");
/* for (var i=0;i<vm.uploadListe.length;i++)
{
console.log(vm.uploadListe[i].imgUrl)
LODOP.ADD_PRINT_IMAGE(0,0,0,0,"<img border='0' src='vm.uploadListe[i].imgUrl'width='100%' height='250'/>");
}*/ /* for (var i=0;i<vm.uploadListe.length;i++)
{
var url = vm.uploadListe[i].imgUrl;
console.log("vm.uploadListe[i].imgUrl"+i+":"+vm.uploadListe[i].imgUrl)
LODOP.ADD_PRINT_IMAGE(113+(i*100),564,184,312,"<img border='0' src='url'width='100%' height='250'/>");
}*/
//LODOP.SET_PRINT_STYLEA(0,'HtmWaitMilSecs',3000)
/*
//直接打印
LODOP.PRINT();
//打印预览
LODOP.PREVIEW();
//打印维护
LODOP.PRINT_SETUP();
//打印设计
LODOP.PRINT_DESIGN();
*/
/*LODOP.PRINT_DESIGN();*/
LODOP.PREVIEW();
/* } else {
alert("LDOP還没准备好!");
} */
};
function print(){
if (needCLodop()) {
window.On_CLodop_Opened = function() {
PreviewMytable();
window.On_CLodop_Opened = null;
};
} else
window.onload = function() {
PreviewMytable();
};
}
</script>
</body>
</html>

lodop 打印的更多相关文章

  1. [原创]Lodop打印, 以及Lodop引用css文件控制打印样式的问题.

    最近在做Lodop打印功能: 思路是:  用MasterPage搭个打印页面的框架, 然后在具体的页面中填入数据, 打印的样式由母版页和CSS来控制. 困扰了一天的问题是:  在打印的JS文件中, 引 ...

  2. chrome升级后LODOP打印插件无法使用

    今天帮朋友使用LODOP实现一个套打程序时,发现LODOP打印插件在chrome下始终无法使用.分析后发现是自己才升级了chrome,chrome新版默认是禁用npapi的,因此需要手动启用一下,启用 ...

  3. LODOP打印控件示例

    一.lodop打印预览效果图 LODOP.PRINT_SETUP();打印维护效果图 LODOP.PREVIEW();打印预览图 二.写在前面 最近项目用到了LODOP的套打,主要用到两个地方,一是物 ...

  4. LODOP打印当前日期时间的方法

    JS方法直接获取.之前有个详细介绍的博文:LODOP打印用JS获取的当前日期本文也再演示一下,详细介绍见上面链接的博文,该方法此文不做详细介绍. 本文有三段:1.JS获取日期,2,.LODOP的FOR ...

  5. LODOP打印用JS获取的当前日期

    该文详细一步步解释JS获取当前时间的方法,新手小白也看到懂,最后是实际的获取当前年月份的方法.JS中的Date()对象,包含很多当前系统时间的方法,首先建立一个Date()对象,这里取名为date,然 ...

  6. Lodop打印控件在页面如何使用

    Lodop打印控件部署到web服务器简单,在页面的使用方法也简单,是非常容易和方便使用的打印控件.客户端本地打印角色(即用户访问网站后 用自己链接的打印机进行客户端本地打印),步骤很少,部署简单:Lo ...

  7. Lodop打印表格带页头页尾 自动分页每页显示头尾

    Lodop中有两种专门给超文本表格的方式,ADD_PRINT_TABLE和ADD_PRINT_TBURL,该方式只能用于单个表格,表格外的内容不显示,是专门用于打印html超文本表格的.使用这两个语句 ...

  8. Lodop打印表格带页头页尾 高度是否包含页头页尾

    通过设置TableHeightScope,可以实现对ADD_PRINT_TABLE,表格带页头页尾,查看本博客另一篇博文:Lodop打印表格带页头页尾 自动分页每页显示头尾 超文本超过打印项高度,会自 ...

  9. Lodop打印控件传入css样式、看是否传入正确样式

    Lodop中可以传入页面存在的css样式,也可以是拼接后的新样式,例如本博客的其他博文:Lodop打印如何隐藏table某一列 需要打印的页面,样式不一定都是行内样式,style样式单独写在页面上,或 ...

  10. Lodop打印控件不打印css背景图怎么办

    background:url()这是css背景图,http协议会按异步方式下载背景图,所以很容易等不到下载完毕就开始打印了,故lodop不打印css背景图.Lodop不打印css背景图,但是有其他方法 ...

随机推荐

  1. HDU 5492 Find a path

    Find a path Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID ...

  2. [luoguP1494] 岳麓山上打水 && [luoguP2744] [USACO5.3]量取牛奶Milk Measuring

    传送门 传送门 dfs选取集合,dp背包判断 虽然我觉的会TLE.. 但是的确是AC了 #include <cstdio> #include <cstring> #includ ...

  3. [luoguP1045] 麦森数(快速幂 + 高精度)

    传送门 这道题纯粹是考数学.编程复杂度不大(别看我写了一百多行其实有些是可以不必写的). 计算位数不必用高精时刻存,不然可想而知时间复杂度之大.首先大家要知道一个数学公式 logn(a*b)=logn ...

  4. VIM使用技巧14

    经常使用vim的童鞋可能会注意到,实际操作过程中,处于插入模式中是非常少的,更多的是查看和浏览,偶尔修改即可.因此,快速从插入模式退出进入普通模式,就显得非常重要.主要有以下四种方式: 一.在插入模式 ...

  5. linux 常见名词及命令(六)

    查看软件安装位置 : dpkg -L 软件包名字 ubuntu环境的apache相关命令: 查看是否启动:ps -aux | grep httpd  或者 netstat -an | grep :80 ...

  6. poj——1422 Air Raid

    Air Raid Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8577   Accepted: 5127 Descript ...

  7. cogs——1001. [WZOI2011 S3] 消息传递

    1001. [WZOI2011 S3] 消息传递 ★★   输入文件:messagew.in   输出文件:messagew.out   简单对比时间限制:1 s   内存限制:128 MB Prob ...

  8. element-ui自定义table表头

    场景描述: 这个需求的场景很简单,表头自定义居中显示 <el-table-column show-overflow-tooltip prop="telephone" labe ...

  9. 携程Apollo(阿波罗)配置中心的Java样例客户端启动和调试

    参考:https://github.com/ctripcorp/apollo/wiki/Apollo%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97#23-java%E6%A0 ...

  10. Java这样学,Offer随便拿,学习方法和面试经验分享

    Java这样学,Offer随便拿,学习方法和面试经验分享 学习中:https://mp.weixin.qq.com/s/iSutLzqCiPMWwm_Rm_2oPw