【问题标题】:Barcode not display in Print Preview - javascript print method条形码不显示在打印预览中 - javascript 打印方法
【发布时间】:2017-01-20 20:48:12
【问题描述】:

我想生成带有条形码的订单收据,但条形码没有显示在打印预览中,而是显示在 html 页面上。 它在我的本地服务器上工作正常。但是在实时服务器上它不起作用。

出于打印目的,我使用了 Javascript 方法。对于使用字体 B39MHR.TTF

的条形码

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();

如果我能得到一些帮助,我将不胜感激。提前致谢。

【问题讨论】:

    标签: javascript php jquery barcode


    【解决方案1】:

    我尝试了很多解决方案,但使用普通的 javascript 是不可能的。 JQPrint 插件在这个问题上为我工作。

    只需要包含 jquery.jqprint-0.3.js javascript 文件和单行 javascript 代码,如下所示,

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

    【讨论】:

      猜你喜欢
      • 2013-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 2014-03-03
      • 1970-01-01
      相关资源
      最近更新 更多