javascript - Calling Functions in QZ-Print Java Applet doesn't work in PHP -
i'm trying use java plugin print raw print ticket printer browser. i've written test program in html , javascript working ok, i'm trying transfer code php script printing tickets in bigger app. i'm gettting kind of error in firefox debug whenever call function app. "typeerror: qz.findprinter not function".
i changed extension on original test program .php .html , i'm recieving error there now.
any functions the java begin "qz."
here's plugin reference https://code.google.com/p/jzebra/wiki/tutorialwebapplet
i figure it's don't know php works ok .html file i've included whole script anyway. php running xampp.
thank 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; < spaceneeded; i++) { spaces += " "; } return (product + spaces + price); } function findprinter() { // searches locally installed printer "zebra" in name qz.findprinter("zebra"); // hint: carriage return = \r, new line = \n, escape double quotes= \" var tickettime = new date(); var singleline = "\n------------------------------------------\n"; var doubleline = "\n==========================================\n"; 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\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; 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 += "\n" } } qz.append("\ndate:" + tickettime.getdate() + "/" + (tickettime.getmonth()+1) + "/" + tickettime.getfullyear() + "\ntime:" + tickettime.gethours() + ":" + tickettime.getminutes() + "\ntable: b10\nticket no:2" //+ singleline + " - 1 " + product1 +" 8.00\n - 1 " + product1 +" 8:00" + singleline + productsec + doubleline + countspace(subtotal.name, subtotal.value,fincharlength) + '\n' + countspace(tax.name, tax.value,fincharlength) + '\n' + countspace(total.name, total.value,fincharlength) + doubleline + ticketend); qz.print(); } </script> <body> <input type="button" onclick="findprinter()" value="print escp" /><br /> </body>
Comments
Post a Comment