简体   繁体   English

条码未显示在打印预览中-JavaScript打印方法

[英]Barcode not display in Print Preview - javascript print method

I want to generate a order receipt with barcode but barcode is not showing in print preview its showing on html page. 我想生成带有条形码的订单收据,但条形码未在打印预览中显示,而是在html页面上显示。 Its working fine on my local server. 它在我的本地服务器上工作正常。 But on live server its not working. 但是在实时服务器上它不起作用。

For printing purpose I have use Javascript method. 出于打印目的,我使用Javascript方法。 For barcode using font B39MHR.TTF 对于使用字体B39MHR.TTF的条形码

Javascript Code ==> JavaScript代码==>

var divToPrint = document.getElementById("manifest");
newWin = window.open("");
newWin.document.write("<link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" media=\"print\"/>");
newWin.document.write('<style type="text/css">  @font-face {font-family: \'B39MHR\';src: url(\'font/B39MHR.TTF\');} .barcodefnt {font-family: B39MHR; font-size: 19px;text-align: center;font-family: \'B39MHR\';src: url(\'font/B39MHR.TTF\')}}</style>');
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();

I will highly appreciate if i can get some help. 如果能得到帮助,我将不胜感激。 Thanks in advance. 提前致谢。

I have tried the many solution but its not possible with normal javascript. 我已经尝试了许多解决方案,但使用普通的javascript无法实现。 The JQPrint plugins is working for me in this issue. JQPrint插件正在为我解决此问题。

For that have to include only jquery.jqprint-0.3.js javascript file & single line javascript code as below, 为此,必须仅包含jquery.jqprint-0.3.js javascript文件和单行javascript代码,如下所示,

$('#sectionID').jqprint(); // sectionID is ID of the section

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM