doueta6642 2015-07-13 15:01 采纳率: 0%
浏览 180

在QZ-Print Java Applet中调用函数在PHP中不起作用

i'm trying use a Java plugin to print to raw print to a ticket printer from a browser. I've written a test program in HTML and Javascript which is working ok, but now i'm trying to transfer the code to a php script for printing tickets in a bigger app. I'm gettting this kind of error in firefox debug whenever i call a function from the app. "TypeError: qz.findPrinter is not a function".

I changed the extension on the original test program to .php from .html and i'm recieving error there too now.

Any functions from the the java begin with "qz."

Here's the plugin for reference https://code.google.com/p/jzebra/wiki/TutorialWebApplet

I figure it's something i don't know about php as it works ok as a .html file but I've included the whole script anyway. The php is running from xampp.

Thank you for you time.

<html>

<head><title>Receipt Test</title>
<script type="text/javascript" src="js/deployJava.js"></script>
<script type="text/javascript">
deployQZ();

function deployQZ() {
    var attributes = {id: "qz", code:'qz.PrintApplet.class', 
        archive:'qz-print.jar', width:1, height:1};
    var parameters = {jnlp_href: 'qz-print_jnlp.jnlp', 
        cache_option:'plugin', disable_logging:'false', 
        initial_focus:'false'};
    if (deployJava.versionCheck("1.7+") == true) {}
    else if (deployJava.versionCheck("1.6+") == true) {
        attributes['archive'] = 'jre6/qz-print.jar';
        parameters['jnlp_href'] = 'jre6/qz-print_jnlp.jnlp';
    }
    deployJava.runApplet(attributes, parameters, '1.5');
}

function countSpace(product, price, section)    {
var spaceNeeded = (section - product.length - price.toString().length);
var spaces = "";
for(i=0; i < spaceNeeded; i++) {
spaces += " ";
    }
return (product + spaces + price);  
}

function findPrinter() {
     // Searches for locally installed printer with "zebra" in the name
     qz.findPrinter("zebra");


     // Hint:  Carriage Return = , New Line = 
, Escape Double Quotes= \"


    var ticketTime = new Date();    
    var singleLine = "
------------------------------------------
";
    var doubleLine = "
==========================================
";
    var product = ["Mirdan Tuzlama", "Suckuklu Pide" ];
    var price = [8.00, 8.00];
    var prodCharLength = 37;
    var finCharLength = 42;
    var subTotal = {name:"Subtotal", value:0};

    for(i=0;i<product.length;i++) {
    subTotal.value += price[i];
    } 

    var tax = {name:"Tax", value:((20/100)*subTotal.value)};
    var total = {name:"Total", value:(subTotal.value-tax.value)}; 
    var ticketEnd = "                Thank You













";
    var productSec = "";
    tax.value = 0 - tax.value;
    for(j=0;j<product.length;j++) {
    var priceloop = price[i];
    productSec += (" - 1 " + countSpace(product[j], price[j],prodCharLength));
        if (j<=(product.length-2)){
        productSec += "
"
        }
    }


    qz.append("
Date:" + ticketTime.getDate() + "/" 
                        + (ticketTime.getMonth()+1) + "/" 
                        + ticketTime.getFullYear() 
            + "
Time:" + ticketTime.getHours() + ":" 
                        + ticketTime.getMinutes() 
            + "
Table: B10
Ticket No:2"               
            //+ singleLine + " - 1 " + product1 +"                   8.00
 - 1 " + product1 +"                    8:00" 
            + singleLine + productSec
            + doubleLine + countSpace(subTotal.name, subTotal.value,finCharLength) 
            + '
' + countSpace(tax.name, tax.value,finCharLength)
            + '
' + countSpace(total.name, total.value,finCharLength)              
            + doubleLine + ticketEnd);

    qz.print(); 

}
</script>

<body>

<input type="button" onClick="findPrinter()" value="Print ESCP" /><br />
</body>
  • 写回答

1条回答 默认 最新

  • douzhuolong9886 2019-01-17 17:29
    关注

    "TypeError: qz.findPrinter is not a function"

    • In QZ "Tray" 1.9 (desktop Application), qz.findPrinter(...) is defined as a preemptive function, created by qz-websocket.js and must be included in your project to be exposed.
      If you didn't include qz-websocket.js, this message will occur.

    • In QZ "Print" 1.9 (Java Applet) and older, qz.findPRinter(...) was exposed through a Java Applet using Java LiveConnect calls, so this was a sign the applet did not load.
      If your applet did not load properly, this message will occur.

    Note: 1.9 was capable of behaving as both a desktop application AND a Java applet.

    Deprecation warning: 1.9 and older are EOL. QZ Tray 2.0 and higher, the API has changed significantly. A migration guide is available.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器