bhupendra21589 / jzebra

Automatically exported from code.google.com/p/jzebra
1 stars 0 forks source link

QZ-Print works in IE but freezes Google Chrome and Firefox #181

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem? - I'm suspecting it is my environment so 
I'm not sure if this will reproduce the issue.
1. ASP.NET 4.0 Website
2. Using Multiple Versions of JQuery in project (img attached)
3. Code Pasted into my page

This HTML
<input type="button" onClick="printEPL()" value="Print EPL" /><br />

...and the entire script block from sample.html 
I am using master pages so this code is also at the bottom of my asp:content 
tag...

<script type="text/javascript" src="js/deployJava.js"></script>
<script type="text/javascript">
    /**
    * Optionally used to deploy multiple versions of the applet for mixed
    * environments.  Oracle uses document.write(), which puts the applet at the
    * top of the page, bumping all HTML content down.
    */
    deployQZ();

    /**
    * Deploys different versions of the applet depending on Java version.
    * Useful for removing warning dialogs for Java 6.  This function is optional
    * however, if used, should replace the <applet> method.  Needed to address 
    * MANIFEST.MF TrustedLibrary=true discrepency between JRE6 and JRE7.
    */
    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');
    }

   .........
..........
    }
</script>
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/html2canvas.js"></script>
<script type="text/javascript" src="js/jquery.plugin.html2canvas.js"></script>

What is the expected output? 
To be able to print in other browsers like I can in IE

What do you see instead?
Nothing, both Firefox and Google Chrome freeze when I try to find the printer. 
(Debugging in VS Express 2012 for Web)

What version of the product are you using? 
qz-print-free_1.7.8

On what operating system?
Windows 7 Professional (VS Express 2012 for Web)

Please provide any additional information below.
I am also using JQuery on the page and implemented the jQuery.noConflicts for 
the pre-existing code on the page like below...I put the qz-print script block 
below the one that contains my pre-existing jquery code...

 <script type="text/javascript">
        var baseJQuery = jQuery.noConflict(true);
        baseJQuery(function () {          

            baseJQuery('#<%= controlid.ClientID %>').datepicker({
                showOn: "button",
                buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
                buttonImageOnly: true
            });

            baseJQuery("#<%= controlid.ClientID %>").change(function () {......
..................

So it works ok in IE and I can print from a button on my page, even with 
modifying the output, but once opened in Firefox or Chrome it freezes. 

Original issue reported on code.google.com by francces...@gmail.com on 16 Nov 2013 at 9:01

GoogleCodeExporter commented 8 years ago
Forgot the image of my jQuery files

Original comment by francces...@gmail.com on 16 Nov 2013 at 9:02

Attachments:

GoogleCodeExporter commented 8 years ago
oops...this is all the HTML I'm using for qz-print, left out a couple of lines

<input type="button" onclick="findPrinter()" value="Detect Printer"/><br />
<input id="printer" type="text" value="EPSON TM-T20 Receipt" size="15"/><br />
<input type="button" onclick="printEPL()" value="Print EPL" /><br />

Original comment by francces...@gmail.com on 16 Nov 2013 at 9:04

GoogleCodeExporter commented 8 years ago
Just switched to version qz-print_1.6.2_src that a coligue of my was working 
with and changed the code on the page to what is below. Now getting the errors 
in the image I attached.

HTML
<asp:Content runat="server" ContentPlaceHolderID="cph">     

   <table border="1px" cellpadding="5px" cellspacing="0px"><tr>

   <td valign="top"><h2>All Printers</h2>
   <input type="button" onclick="findPrinter()" value="Detect Printer"/><br />
   <applet id="qz" name="QZ Print Plugin" code="qz.PrintApplet.class" archive="qz-print/qz-print.jar" width="50px" height="50px">
      <!-- Optional, searches for printer with "zebra" in the name on load -->
      <!-- Note:  It is recommended to use qz.findPrinter() instead for ajax heavy applications -->
      <param name="printer" value="EPSON TM-T20 Receipt"/>
      <!-- ALL OF THE CACHE OPTIONS HAVE BEEN REMOVED DUE TO A BUG WITH JAVA 7 UPDATE 25 -->
      <!-- Optional, these "cache_" params enable faster loading "caching" of the applet -->
      <!-- <param name="cache_option" value="plugin"> -->
      <!-- Change "cache_archive" to point to relative URL of qz-print.jar -->
      <!-- <param name="cache_archive" value="./qz-print.jar"> -->
      <!-- Change "cache_version" to reflect current qz-print version -->
      <!-- <param name="cache_version" value="1.4.9.1"> -->
   </applet><br />

   </td><td valign="top"><h2>Raw Printers Only</h2>
   <a href="http://code.google.com/p/jzebra/wiki/WhatIsRawPrinting" target="new">What is Raw Printing?</a><br />
   <input type="button" onclick="print()" value="Print" /><br />
       </td></tr>     
 </table>
..............
..............

SCRIPT
<script type="text/javascript">
    var qz;   // Our main applet
    function findPrinter() {

        if (qz != null) {
            // Searches for locally installed printer with "zebra" in the name
            qz.findPrinter("EPSON TM-T20 Receipt");
        }

        // *Note:  monitorFinding() still works but is too complicated and
        // outdated.  Instead create a JavaScript  function called 
        // "jzebraDoneFinding()" and handle your next steps there.
        monitorFinding();
    }

    function findPrinters() {

        if (qz != null) {
            // Searches for locally installed printer with "zebra" in the name
            qz.findPrinter("\\{dummy printer name for listing\\}");
        }

        monitorFinding2();
    }
...........
...........

Original comment by francces...@gmail.com on 16 Nov 2013 at 9:36

Attachments:

GoogleCodeExporter commented 8 years ago
Second way also still works in IE but Chrome and Firefox throw the error in the 
image

Original comment by francces...@gmail.com on 16 Nov 2013 at 9:40

GoogleCodeExporter commented 8 years ago
@franccescalee:

Incompatible magic value is generally a sign that the Jar file is corrupt.

The deployJava() function from Oracle I'm finding has several problems.

Please note, since 1.7.0, your applet tags should look like this:

<applet id="qz" archive="./qz-print.jar" name="QZ Print Plugin" 
code="qz.PrintApplet.class" width="55" height="55">
    <param name="jnlp_href" value="qz-print_jnlp.jnlp">
    <param name="cache_option" value="plugin">
    <param name="disable_logging" value="false">
    <param name="initial_focus" value="false">
</applet>

Lastly, note that IIS users need to allow JNLP file extensions, Issue 171.

-Tres

Original comment by tres.fin...@gmail.com on 17 Nov 2013 at 1:46

GoogleCodeExporter commented 8 years ago
One more thing... if the browser is complete freezing, it is likely a bug with 
Java.

It has been plaguing the project for years, but I've had a hard time 
pinpointing it...

- Sometimes it is timing related to when the applet tags are loaded.
- I've read that some versions of jQuery don't play nicely with applets.
- Sometimes the applet is persistent and it crashes the browser on refresh or 
back/forward.
- For some its just been caused by an invalid JNLP path

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6668033
http://stackoverflow.com/questions/7885715/java-applet-deadlock-on-chrome-on-win
-7-64-with-either-jre-1-6-0-29-or-1-7-0-1
https://groups.google.com/forum/#!topic/jquery-dev/xnSD5Yyqy_0

Original comment by tres.fin...@gmail.com on 17 Nov 2013 at 2:03

GoogleCodeExporter commented 8 years ago
- Added workaround for possible browser lock-up, documented here:
   https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/331962

One poster suggests this seems to affect many platforms (i.e. Windows) let me 
know if this addresses any of the sporadic lock-up issues.

-Tres

Original comment by tres.fin...@gmail.com on 5 Dec 2013 at 3:47

GoogleCodeExporter commented 8 years ago
^--- 1.8.0 and higher. :)

Original comment by tres.fin...@gmail.com on 5 Dec 2013 at 3:47

GoogleCodeExporter commented 8 years ago

Original comment by tres.fin...@gmail.com on 5 Dec 2013 at 3:49

GoogleCodeExporter commented 8 years ago
same problem here (since updating to jquery 1.10.2)

Original comment by andreas....@gmail.com on 30 Dec 2013 at 3:56

GoogleCodeExporter commented 8 years ago
I've had a client suggest changing cache_option to "no" had helped with this 
issue.  Please test and post your progress.

Original comment by tres.fin...@gmail.com on 19 Jan 2014 at 4:15

GoogleCodeExporter commented 8 years ago
Hi Guys, i have the same issue, my browser freeze when i reload usign f5 or 
ctrl + r or use back nav button, after googling around i found this:

<param name="cache_option" value="plugin">
<param name="cache_archive" value="<?php echo base_url(); ?>qz-print.jar">

the problem seems to be solved!

Original comment by MatheusD...@gmail.com on 28 Jan 2014 at 4:11

GoogleCodeExporter commented 8 years ago
@Matheus,

I've had people emailing various work-arounds but none of them seem to be 
universal.  Any confirmation on this would be fantastic.

To do this via deployJava would look like this:

    var parameters = {
       jnlp_href: 'qz-print_jnlp.jnlp', 
       cache_option:'plugin', 
       cache_archive:'qz-print.jar',
       disable_logging:'false', 
       initial_focus:'false'
    };

Caching has caused some troubles with clients when they upgrade, so we've had 
mixed feeling and mixed success, so I'd like some more feedback before changing 
this in sample.html.

-Tres

Original comment by tres.fin...@gmail.com on 28 Jan 2014 at 6:40