javaScript 连接打印机,打印小票实例分享
本文主要为大家分享一篇javaScript 链接打印机,打印小票的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧,希望能帮助到大家。
如下所示:
<%@ 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 > <p 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> </p> <!--startprint--> <br> <p 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--> </p> </body> </html>
相关推荐:
javascript 打印页面代码_javascript技巧
javascript 打印内容方法小结_javascript技巧
以上是javaScript 连接打印机,打印小票实例分享的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

如果您在使用打印机时遇到错误消息,例如操作无法完成(错误0x00000771),可能是因为打印机已断开连接。在这种情况下,您可以通过以下方法解决问题。在本文中,我们将讨论如何在Windows11/10PC上修复此问题。整个错误信息说:操作无法完成(错误0x0000771)。指定的打印机已被删除。修复WindowsPC上的0x00000771打印机错误若要修复打印机错误操作无法完成(错误0x0000771),指定的打印机已在Windows11/10PC上删除,请遵循以下解决方案:重新启动打印假脱机

如果在打印Excel工作表或PowerPoint演示文稿时遇到打印机内存不足的问题,这篇文章可能对您有所帮助。您可能收到类似的错误消息,指出打印机内存不足,无法打印页面。不过,您可以遵循一些建议来解决这个问题。为什么打印时打印机内存不可用?打印机内存不足可能导致内存不可用错误。有时是由于打印机驱动程序设置过低,也可能是其他原因。大文件大小打印机驱动程序过时或损坏来自已安装的加载项的中断打印机设置配置错误发生此问题也可能是因为MicrosoftWindows打印机驱动程序上的内存设置较低。修复打印

如果您在Windows11/10中无法使用截图工具进行打印,可能是由于系统文件损坏或驱动程序问题导致的。本文将为您提供解决此问题的方法。在Windows11/10中无法从截图工具打印如果您无法从Windows11/10中的SnippingTool打印,请使用这些修复程序:重新启动PC打印机清除打印队列更新打印机和显卡驱动程序修复或重置剪裁工具运行SFC和DISM扫描使用PowerShell命令卸载并重新安装截图工具。我们开始吧。1]重新启动您的PC和打印机重新启动电脑和打印机有助于消除暂时的故障

我们使用办公软件可以制作各种电子文件,电子文件大大的节省了纸张的使用,也更容易保存和翻阅,但是有时候根据工作的要求,上级要求打印出纸质的文件方便大家传阅,文件写好了却无法打印,遇到这样的情况很棘手,今天我们带来的课程就可以解决这个难题。下面的课程就是:wps无法启动打印机作业怎么办?当尝试使用局域网打印机打印文档时,出现了一个问题,显示"WPSOffice无法启动打印作业,请检查打印机是否开机并联机"。但实际上,打印机是开机的并且也已经联机。 2、点击“确定”,然后点击标题栏的左上角如图所示的

本站4月30日消息,联想小新PandaPro熊猫打印机Pro目前已经上架京东,这款打印机将于5月6日开售,支持黑白激光打印,可选双色机身,内置学习资源,首发价999元。联想小新熊猫打印机Pro三围350x275x141mm,提供西岭白与青城灰两种配色可选。这款打印机支持2.4GHz/5GHz双频Wi-Fi、USB有线等连接方式,配网后即可一键打印,还可实现NFC一碰打印。小新熊猫打印机Pro支持黑白激光打印,每分钟可打印22页。除打印功能外,该机型还支持复印与扫描功能,彩色扫描分辨率达4800d

手机直连打印机成为了现代生活中一种越来越受欢迎的打印解决方案,随着移动设备的普及和功能的不断增强。快速实现文件的打印,我们可以在不需要电脑的情况下、通过手机直连打印机。帮助您选择最适合自己需求的打印方案、本文将为您介绍手机直连打印机的各种连接方式。Wi-Fi直连打印Wi-Fi直连打印是目前最常见的手机直连打印机连接方式之一。通过将打印机与手机连接至同一Wi-用户可以通过手机应用程序轻松实现文件的传输和打印、Fi网络。蓝牙直连打印蓝牙直连打印是一种更加简单便捷的手机直连打印机连接方式。即可实现文件

其实就是局域网打印机共享,方法如下:1、给打印机设置IP,先把路由器或者是交换机引出来的网上插到打印机上面。2、然后点击打印机设置——网络配置——无线菜单,最好是在里面给打印机设置一个固定的IP。接下来,在电脑上下载并安装打印机的驱动程序。在安装驱动时,选择网络安装选项,这样计算机会自动搜索连接局域网内共享的打印机。安装完成后,驱动程序将显示打印机已成功进行无线共享。通过无线网络连接打印机的方法:1、右键点击桌面下的WiFi图标,选择“打开网络和共享中心”。2、点击已连接到的WiFi的名称,弹出

人脸检测识别技术已经是一个比较成熟且应用广泛的技术。而目前最为广泛的互联网应用语言非JS莫属,在Web前端实现人脸检测识别相比后端的人脸识别有优势也有弱势。优势包括减少网络交互、实时识别,大大缩短了用户等待时间,提高了用户体验;弱势是:受到模型大小限制,其中准确率也有限。如何在web端使用js实现人脸检测呢?为了实现Web端人脸识别,需要熟悉相关的编程语言和技术,如JavaScript、HTML、CSS、WebRTC等。同时还需要掌握相关的计算机视觉和人工智能技术。值得注意的是,由于Web端的计
