Jspdf没有在IE11上工作

时间:2016-05-05 14:59:52

标签: javascript jquery jquery-plugins jspdf

我是初学者,我正在尝试以PDF格式导出我的视图,它正在使用chrome但是当我尝试在ie11文件中导出PDF时不下载并且在控制台上没有显示任何错误。我正在使用jsPDF将我的视图导出为PDF。

ExportpdfDoc: function (data, dashboard) {
    //var pdf = new jsPDF('landscape', 'pt', 'letter');
    // var pdf = new jsPDF()//'l', 'mm', [297, 300]          
    var pdf = new jsPDF('p', 'pt', 'a3', false);
    var dashboardData = bi_export.formtating(data, pdf);
    //$("#dashboardTables").show();//Now dont need to show .
    $("#dashboardTables").append(dashboardData)
    pdf.setProperties({
        title: 'Dashboard Pdf',
        subject: '',
        author: '',
        keywords: '',
        creator: ''
    });
    var tblClone = "";
    //pdf.setFont("courier", "normal");
    pdf.image_compression.none;
    // pdf.text("Left aligned text", 0.5, 0.5);

    var height = $("#userDashboardArea").height();
    var options = {
        //pagesplit: false,
    };
    var options1 = {
        pagesplit: false,
    };
    //var options = {
    //    orientation: "l",
    //    unit: "pt",
    //    format: "letter"
    //};
    var count = 0;
    var y = 0;
    var specialElementHandlers = {
        '#btnEditRptHeader': function (element, renderer) {
            return true;
        }
    }
    //$("#userDashboardArea ul").each(function (i, ul) {
    //    var colid = $(ul).attr('id');

    //    if (colid == undefined) {
    //        $(ul).hide()
    //    }
    //    else {
    //        if ($("#" + colid).html() == "") {

    //            $("#" + colid).remove();
    //        }
    //    }

    //    $($("#" + colid).children('li')).each(function (i, li) {
    //        var itemtype = $(li).attr('itemtype');
    //        if (itemtype == '1') {
    //            //var tableHTML = $($(li).find("table")).html();
    //            //tblClone = $($(li).find("table")).clone();
    //            //var width = $($(li).find("table")).width();
    //            //var height = $($(li).find("table")).height();
    //            //var tblID = $($(li).find("table")).attr('id');
    //            //var ds = $("#" + tblID).igGrid("option", "dataSource")

    //            //table = $.makeTable(ds["Records"]);
    //            //$(table).width(width);
    //            //$(table).height(height);

    //            //$("#" + tblID).html('');
    //            //$(table).appendTo("#" +tblID);
    //            //$($(li).find(".ui-iggrid-toolbar")).hide()
    //            //var height = $($(li).find("table")).height();
    //            //$("#" + colid).height(height+100);
    //            // });
    //        }
    //    });

    //});
    var title = $("#content .to-let-heading").text();
    $("#" + dashboard).find(".editbtn-bg").before('<h3 class=pdfTitle style=height: 50px;background-color: white!important;>' + title + '</h3>');
    var page1Height = $("#" + dashboard).height();
   // page1Height -= (page1Height / 10) * 3;
    pdf.addPage(840, page1Height);
    pdf.deletePage(1);
    pdf.addHTML($("#" + dashboard), 0, 5, options, function () {

        //'l', 'mm', [297, 210], 'a3'
        // pdf.setFontSize(7);
        var height = $("#dashboardTables").height();
        height -= (height / 10) * 3;
        var width = $("#dashboardTables").width();

        pdf.addPage(840, height);

        //experiment start

        margins = {
            top: 80,
            bottom: 60,
            left: 40,
            width: width
        };

        pdf.fromHTML(
        $("#dashboardTables").html() // HTML string or DOM elem ref.
        , 10 // x coord
        , 10 // y coord
        , {
            'width': width // max width of content on PDF
            , 'elementHandlers': specialElementHandlers
        },
        function (dispose) {
            // dispose: object with X, Y of the last line add to the PDF
            //          this allow the insertion of new lines after html
            pdf.save(title + '.pdf');
            $("#dashboardTables").html('');
        },
        margins
      )
        // experiment end

        //pdf.addHTML($("#dashboardTables"), 0, 10, options, function () {
        //   pdf.save();
        // $("#dashboardTables").html('');
        //});
    });

    $("#" + dashboard).find(".pdfTitle").remove();
}

0 个答案:

没有答案