From 190e3c0a34847bb3e45ea79c62668f30dc21122d Mon Sep 17 00:00:00 2001 From: yanjunjie <1403270268@qq.com> Date: Thu, 2 Jun 2022 11:05:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=B3=E9=94=AE=E8=8F=9C?= =?UTF-8?q?=E5=8D=95z-index999=20=E4=BC=98=E5=8C=96toPdf=EF=BC=8Coptions?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=AF=E9=80=89=E5=8F=82=E6=95=B0idDownloa?= =?UTF-8?q?d=E9=BB=98=E8=AE=A4=E4=B8=BAtrue=E7=9B=B4=E6=8E=A5=E4=B8=8B?= =?UTF-8?q?=E8=BD=BDpdf=EF=BC=8Cfalse=E6=97=B6=E8=BF=94=E5=9B=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hiprint/hiprint.bundle.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/hiprint/hiprint.bundle.js b/src/hiprint/hiprint.bundle.js index 8f235e8..dc1a286 100644 --- a/src/hiprint/hiprint.bundle.js +++ b/src/hiprint/hiprint.bundle.js @@ -6562,7 +6562,7 @@ var hiprint = function (t) { i = e; if (t && t.length) { - var o = $(''); + var o = $(''); i || (i = o).addClass("hicontextmenuroot"), $.each(t, function (t, e) { var i = !!e.disable && e.disable(), r = $('
  • ' + (e.text || "") + "
  • "); @@ -8797,7 +8797,8 @@ var hiprint = function (t) { }); }, t.prototype.toPdf = function (t, e, n) { var i = this; - + var dtd = $.Deferred(); + var isDownload = true; if (this.printPanels.length) { var r = o.a.mm.toPt(this.printPanels[0].width), a = o.a.mm.toPt(this.printPanels[0].height), @@ -8814,6 +8815,9 @@ var hiprint = function (t) { format: this.printPanels[0].paperType ? this.printPanels[0].paperType.toLocaleLowerCase() : [r, a] }), l = this.getHtml(t, n); + if(n.hasOwnProperty("isDownload")){ + isDownload = n.isDownload + } this.createTempContainer(); var u = this.getTempContainer(); this.svg2canvas(l), u.html(l[0]); @@ -8825,10 +8829,17 @@ var hiprint = function (t) { for (var o = t.toDataURL("image/jpeg"), p = 0; p < d; p++) { s.addImage(o, "JPEG", 0, 0 - p * a, r, d * a), p < d - 1 && s.addPage(); } - - i.removeTempContainer(), e.indexOf(".pdf") > -1 ? s.save(e) : s.save(e + ".pdf"); + if(isDownload){ + i.removeTempContainer(),e.indexOf(".pdf") > -1 ? s.save(e) : s.save(e + ".pdf"); + } else{ + i.removeTempContainer(); + var pdfFile = s.output('blob'); + //var file = new File([pdfFile], e.name.indexOf(".pdf") > -1 ? e.name : e.name + ".pdf", {type: 'application/pdf', lastModified: Date.now()}); + dtd.resolve(pdfFile); + } }); } + return dtd.promise(); }, t.prototype.createTempContainer = function () { this.removeTempContainer(), $("body").prepend($('
    ')); }, t.prototype.removeTempContainer = function () { -- Gitee