使用qzprint(jzebra)时IE和未指定的错误

时间:2014-05-06 19:36:43

标签: javascript jquery internet-explorer html2canvas

您好我正在尝试打印HTML页面。 它在IE以外的所有其他浏览器中打印。 在IE中,它在html2canvas.js中给出了“未指定的错误” html2canvas.js的版本是0.34。 我尝试过使用最新版本viz 0.4.1,但在其他方面失败了。 随applet提供的sample.html工作正常,我的大部分代码都是从那里借来的。

错误发生在html2canvas.js

中以下代码的最后一行
_html2canvas.Util.Bounds = function getBounds (el) {
    var clientRect,
    bounds = {};

    if (el.getBoundingClientRect){
        clientRect = el.getBoundingClientRect();

非常感谢任何线索和提示。

这是我的代码

$(document).ready(function () {

    useDefaultPrinter(function () {

        if (!isLoaded()) {
            alert("Printer is not loaded, please try again.");
            return;
        }

        window['qzDonePrinting'] = function () {
            // After print functionality
            if ($('input[name=action]').length > 0)
                document.getElementById('frm_next').submit();
            else {
                var query_param = 'coid=8EY76KFTYGWF6';
                send_ajax_request(query_param, function () {
                    var href = '/path/to/homepage';
                    if (JSON_data.SUCCESS == 1)
                        href += '?coid=' + JSON_data.RET_COID;
                    window.location.href = href;
                });
            }

            // Remove reference to this function
            window['qzDonePrinting'] = null;
        };
        printHTML5Page();
    });
});

function printHTML5Page() {
   $("body").html2canvas({
      canvas: hidden_screenshot,
      onrendered: function() {
         if (notReady()) { return; }
         // Optional, set up custom page size.  These only work for PostScript printing.
         // setPaperSize() must be called before setAutoSize(), setOrientation(), etc.
         qz.setPaperSize("8.5in", "11.0in");  // US Letter
         qz.setAutoSize(true);
         qz.appendImage($("canvas")[0].toDataURL('image/png'));
         // Automatically gets called when "qz.appendFile()" is finished.
         window['qzDoneAppending'] = function() {
            // Tell the applet to print.
            qz.printPS();

            // Remove reference to this function
            window['qzDoneAppending'] = null;
         };
      }
   });
}

提前感谢所有输入。

1 个答案:

答案 0 :(得分:0)

html2canvas依赖于旧版Internet Explorer的HTML5规范。您的浏览器可能不支持此功能,具体取决于您的IE版本。

相关问题