国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

javaScript 連接打印機,打印小票的實例

2024-05-06 16:41:41
字體:
來源:轉載
供稿:網友

如下所示:

<%@ page contentType="text/html;charset=UTF-8"%><%@ include file="/webpage/include/taglib.jsp"%><!-- <!DOCTYPE html> --><html><head><meta name="decorator" content="default" /><script type="text/javascript" src="${ctxStatic}/jquery-ztree/3.5.12/js/jquery-1.4.4.min.js"></script><script type="text/javascript" src="${ctxStatic}/newStyle/jsPdf.debug.js"></script><script type="text/javascript" src="${ctxStatic}/newStyle/html2canvas.js"></script><script type="text/javascript">function doPrint(){    bdhtml=window.document.body.innerHTML;    sprnstr="<!--startprint-->";    eprnstr="<!--b-->";    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));    window.document.body.innerHTML=prnhtml;    window.print();    top.layer.closeAll();   }function closes (){  top.layer.closeAll();}function downPdf(){ document.getElementById("dayin").style.display = "none"; document.getElementById("baocun").style.display = "none";  html2canvas(document.body, {   onrendered:function(canvas) {    var contentWidth = canvas.width;    var contentHeight = canvas.height;    //一頁pdf顯示html頁面生成的canvas高度;    var pageHeight = contentWidth / 592.28 * 841.89;    //未生成pdf的html頁面高度    var leftHeight = contentHeight;    //pdf頁面偏移    var position = 0;    //a4紙的尺寸[595.28,841.89],html頁面生成的canvas在pdf中圖片的寬高    var imgWidth = 595.28;    var imgHeight = 592.28/contentWidth * contentHeight;    var pageData = canvas.toDataURL('image/jpeg', 1.0);    var pdf = new jsPDF('', 'pt', 'a4');    //有兩個高度需要區分,一個是html頁面的實際高度,和生成pdf的頁面高度(841.89)    //當內容未超過pdf一頁顯示的范圍,無需分頁    if (leftHeight < pageHeight) {     pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight );    } else {     while(leftHeight > 0) {      pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)      leftHeight -= pageHeight;      position -= 841.89;      //避免添加空白頁      if(leftHeight > 0) {       pdf.addPage();      }     }    }    pdf.save(document.getElementById("emNo").innerText+"("+document.getElementById("dt").innerText+').pdf');   }  })  document.getElementById("baocun").style.display = "";  document.getElementById("dayin").style.display = "";}</script></head><body ><div style="width: 800px;height: 35px;"> <button id="dayin" onclick="doPrint()" class="" style="border-bottom:1px solid #0071ce;float: right;background: #0071ce;color:rgb(255, 255, 255);font-size:13px;margin-right: 10px; margin-top: 10px;"><i class="fa fa-print"></i>打印</button> <button id="baocun" onclick="downPdf()" class="" style="border-bottom:1px solid #0071ce;float: right;background: #0071ce;color:rgb(255, 255, 255);font-size:13px;margin-right: 10px; margin-top: 10px;"><i class="fa fa-print"></i>保存</button></div><!--startprint--><br> <div id="print" style="padding-left: 15px; padding-right: 15px;">  <table style="width: 100%">   <tr>    <td colspan="8" style="text-align: center;font-size: 20px;">新XXXXX物業服務中心</td>   </tr>   <tr >    <td colspan="8"style="text-align: center;font-size: 14px;padding-top: 10px;">收費單據</td>   </tr>   <tr>    <td colspan="2">收票類型:電費</td>    <td colspan="3"></td>    <td>繳費日期:</td>    <td colspan="2" id="dt">${emfee.dt}</td>   </tr>   <tr>    <td style="text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">戶名</td>    <td style="text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.userName}</td>    <td style="text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">表號</td>    <td id="emNo" colspan="2" style="text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.emNo}</td>    <td style=" text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">房號</td>    <td colspan="2" style=" text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.num}</td>   </tr>   <tr>    <td style=" text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">起止時間</td>    <td colspan="3" style=" text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.emDt}至${emfee.startDt}</td>    <td style=" text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">繳費金額</td>    <td style=" text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.tranMoney}</td>    <td style="text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">倍率</td>    <td style="text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.emRate}</td>   </tr>   <tr>    <td rowspan="6" style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;">用電量</td>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">時段</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">起止表碼</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">倍率前用量</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">本次用量</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">單價</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">本次電費</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">尖</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.mosaicJian}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.jianQuantity}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.blJian}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.jian}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.jianFee}</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">峰</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.mosaicFeng}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.fengQuantity}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.blFeng}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.feng}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.fengFee}</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">平</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.mosaicPing}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.pingQuantity}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.blPing}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.ping}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.pingFee}</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">谷</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.mosaicGu}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.guQuantity}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.blGu}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.gu}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.guFee}</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">總</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.mosaicZong}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.quantity}</td>    <td style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">${emfee.blquantity}</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">——</td>    <td style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;">${emfee.electFee}</td>   </tr>   <tr>    <td rowspan="2" style="text-align: center;font-size: 14px;height:40px;border:1px solid #000000;">電費</td>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">上次剩余(元)</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">本期已用(元)</td>    <td colspan="2" style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">本次繳費(元)</td>    <td colspan="2" style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;border-bottom:0px solid #000000;">本次剩余(元)</td>   </tr>   <tr>    <td style="width: 12%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;">${emfee.lastRemainQ}</td>    <td colspan="2" style="width: 13%; text-align: center ;font-size: 14px;height: 40px;border:1px solid #000000;">${emfee.electFee}</td>    <td colspan="2" style="width: 12%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;">${emfee.tranMoney}</td>    <td colspan="2" style="width: 13%; text-align: center;font-size: 14px;height: 40px;border:1px solid #000000;">${emfee.remainQ}</td>   </tr>   <tr>    <td colspan="2" style="text-align: center;font-size: 14px;height: 40px;"></td>    <td style="text-align: center;font-size: 14px;height: 40px;">收款人:</td>    <td colspan="2" style="text-align: center;font-size: 14px;height: 40px;"></td>    <td style="text-align:center ;font-size: 14px;height: 40px;">付款人:</td>    <td colspan="2" style="text-align:center ;font-size: 14px;height: 40px;"></td>   </tr>  </table> <!--b--> </div></body></html>

以上這篇javaScript 連接打印機,打印小票的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和平县| 伊宁市| 江达县| 合江县| 威信县| 通榆县| 黑山县| 广汉市| 武强县| 梧州市| 元氏县| 沽源县| 阿城市| 新密市| 遂平县| 汕尾市| 阿拉善盟| 黄冈市| 炎陵县| 芷江| 方山县| 浦东新区| 临颍县| 新蔡县| 徐州市| 罗城| 玉环县| 焦作市| 锦屏县| 嫩江县| 延川县| 丹阳市| 竹山县| 炉霍县| 定安县| 揭阳市| 瑞丽市| 鄂伦春自治旗| 常州市| 金阳县| 外汇|