发生了一些事情,PDF不再在新的浏览器选项卡中打开

时间:2017-08-14 19:32:43

标签: jspdf-autotable

我在ReactJS应用程序中运行pdf-autotable v2.3.2和jspdf v1.3.3。我没有更改任何代码,但以前显示在新Chrome标签中(看起来很漂亮,BTW)的PDF现在不再显示了。

BASE64,JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9 ...(几千个字符)... Ci9CaXRzUGVyQ29tcG9uZW50IDgKL0ZpbHRlciAvRENURGVjb2RlCi9MZW5ndGggNDAyMj4 + CnN0cmVhbQr / 2P / hABhFeGlmAABJSSoACAAAAAAAAAAAAAAA / + wAEUR1Y2t5AAEABAAAADwAAP / hAzFodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvADw / eHBhY2tldCBiZWdpbj0i77u / IiBpZD;应用/ PDF:

在选项卡的标题无标题,像数据的URL打开%E2%80%A6%E2%80%A6和空白网页。

我的pdf / autotable代码是:

ResultSet rs = stmt.executeQuery= ("
SELECT COLUMN1 as ""STRING WITH SPACE"" ex EMPLOYEE NAME
FROM TABLE1 
WHERE CONDITION1 = CONDITION
");

然后我注释掉了我自己的所有代码并粘贴在最简单的例子中:

  printGrid() {
    let doc = new jsPDF('landscape');
    const totalPagesExp = "{total_pages_count_string}";

    let pageContent = function (data) {

        // HEADER
        doc.setFontSize(20);
        doc.setTextColor(40);
        doc.setFontStyle('normal');
        doc.addImage(getBase64ImgGlobal(), 'JPEG', data.settings.margin.left, 15, 10, 10);
        doc.text(fullReportName, data.settings.margin.left + 15, 22);

        // FOOTER
        var str = "Page " + data.pageCount;
        if (typeof doc.putTotalPages === 'function') {
            str = str + " of " + totalPagesExp;
        }
        doc.setFontSize(10);
        doc.text(str, data.settings.margin.left, doc.internal.pageSize.height - 10);
    };

    let _this = this;

    doc.autoTable(this.getPdfColumns(), this.getPdfData(), {
        addPageContent: pageContent,
        margin: {top: 30},
        createdHeaderCell: function(cell, data) { _this.alignCol(cell, data) },
        createdCell: function(cell, data) { _this.alignCol(cell, data) }
    });

    if (typeof doc.putTotalPages === 'function') {
        doc.putTotalPages(totalPagesExp);
    }

    doc.setProperties({
      title: fullReportName
    });

    doc.output('dataurlnewwindow');
  };

同样的事情发生了。求助。

1 个答案:

答案 0 :(得分:0)

尝试使用doc.save()代替doc.output()