当前位置: 代码迷 >> 综合 >> 导出pdf文档
  详细解决方案

导出pdf文档

热度:81   发布时间:2024-01-26 15:37:03.0

getPointTable: function () {

    let code = this.editMessionShip;

    $(function(){

        $('title').html('出海工作登记表('+ code +')') // 此处也可以使用text()方法

    })

    $("#iframe").remove()

    bdhtml = window.document.body.innerHTML;

    sprnstr = "<!--startprints-->"; //开始打印标识字符串有17个字符

    eprnstr = "<!--endprints-->"; //

    prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 18); //从开始打印标识之后的内容

    prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); //截取开始标识和结束标识之间的内容

$(".manage-seaMission").append(`<iframe width='100%' height='200px' ref='iframe' style='display: none;' id='iframe'></iframe>`)

$("#iframe")[0].contentWindow.document.write(`<html>

<head>

<title>出海工作登记表</title>

<style media="print">

@media print {

body{

-webkit-print-color-adjust:exact;

-moz-print-color-adjust:exact;

-ms-print-color-adjust:exact;

print-color-adjust:exact;

}

}

</style>

</head>

<body>

    ${prnhtml}</div>

</body>

</html>`)

setTimeout(function () {

    $("#iframe")[0].contentWindow.print()

    $(function(){

        $('title').html('海上人员安全&风场安防系统!') // 此处也可以使用text()方法

    })

}, 0)

// window.document.body.innerHTML=prnhtml; //把需要打印的指定内容赋给body.innerHTML

// window.print(); //调用浏览器的打印功能打印指定区域

// window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;

// window.location.reload();

// return false;

},

  相关解决方案