单击打印按钮时,某些用户不会出现打印对话框

问题描述 投票:0回答:1

当我要单击“打印”按钮时,打印对话框在我这边工作正常,但一些用户抱怨他们在单击“打印”按钮进入生产站点后没有获得打印对话,我已从本地和生产端进行检查,但双方工作正常,无法从我这边发现任何问题,请提出建议。

下面是我的html

enter image description here

下面是我单击按钮时的角度分量方法

  public downloadPDF() {
    var printContents = document.getElementById('contentToConvert').innerHTML;
    debugger;
    if (this.Popup(printContents)) {
    }
  }

 Popup(data) {
    debugger;
    var mywindow = window;
    if (this.islogo)
    mywindow.document.write('<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css" /><style>.container-fluid {width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto}div {box-sizing: border-box}.label {font-weight: 600 !important;margin-right: 5px !important;}label {display: inline-block;margin-bottom: .5rem}.items-group {border-style: solid;border-color: #000;border-width: 1pt 1pt 1pt 1pt;border-radius: 5pt;padding: 3pt 3pt 3pt 3pt;margin: 9pt 0 9pt 0}.logotipo {width: 6cm;height: 4cm;margin: -.5cm}.label {font-weight: 500}.address p, .disclaimer {font-size: 10pt}.signature-ield {padding-bottom: 24pt;border-bottom: solid #000 1pt}.align-r {text-align: right}.align-l {text-align: left}.align-c {text-align: center}.border-none {border: none !important}.col-1 {flex: 0 0 .33333333%;max-width: 8.33333333%}.col-12 {flex: 0 0 100%;max-width: 100%;}.col-4 {flex: 0 0 33.33333333%;max-width: 33.33333333%;}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}.col-5 {flex: 0 0 41.66666667%;max-width: 41.66666667%}.col-3 {flex: 0 0 25%;max-width: 25%}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {width: 100%;position: relative;min-height: 1px;display: inline-block}.float-left {float: left !important}.col-10 {flex: 0 0 83.33333333%;max-width: 83.33333333%}.col-2 {flex: 0 0 16.66666667%;max-width: 16.66666667%;}.col-6 {flex: 0 0 50%;max-width: 50%}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}h1 {font-size: 18pt;font-weight: 500;margin-bottom: .5cm}.card-title, .text-title, h1, h2, h3, h4, h5, h6 {color: #332e38}.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {font-family: inherit;font-weight: 500;line-height: 1.2}.h4, h4 {font-size: 1.2195rem}header {font-size: 10px}@page {size: A4;margin-top: 11mm;margin-bottom: 5mm;margin-left: 11.98mm;margin-right: 11.98mm}.page-header, .page-header-space {height: 100px;}.page-footer, .page-footer-pace{height: 80px;}.page-footer {position: fixed;bottom: 0;width: 100%;padding-left: 20px;/*border-top: 1px solid black; for demo *//*background: yellow; for demo */}.page-header {position: fixed;top: 0mm;width: 100%;/*border-bottom: 1px solid black; for demo *//*background: yellow; for demo */padding-left: 20px;}.page {page-break-after: always;}@page {margin: 20mm}@media print {thead {display: table-header-group;}tfoot {display: table-footer-group;}button {display: none;}body {margin: 0;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;letter-spacing: .3px;line-height: 1.6;}}</style></head><body><div class="page-header" style="z-index:1000;background: white">');
    else
    mywindow.document.write('<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css" /><style>.container-fluid {width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto}div {box-sizing: border-box}.label {font-weight: 600 !important;margin-right: 5px !important;}label {display: inline-block;margin-bottom: .5rem}.items-group {border-style: solid;border-color: #000;border-width: 1pt 1pt 1pt 1pt;border-radius: 5pt;padding: 3pt 3pt 3pt 3pt;margin: 9pt 0 9pt 0}.logotipo {width: 6cm;height: 4cm;margin: -.5cm}.label {font-weight: 500}.address p, .disclaimer {font-size: 10pt}.signature-ield {padding-bottom: 24pt;border-bottom: solid #000 1pt}.align-r {text-align: right}.align-l {text-align: left}.align-c {text-align: center}.border-none {border: none !important}.col-1 {flex: 0 0 .33333333%;max-width: 8.33333333%}.col-12 {flex: 0 0 100%;max-width: 100%;}.col-4 {flex: 0 0 33.33333333%;max-width: 33.33333333%;}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}.col-5 {flex: 0 0 41.66666667%;max-width: 41.66666667%}.col-3 {flex: 0 0 25%;max-width: 25%}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {width: 100%;position: relative;min-height: 1px;display: inline-block}.float-left {float: left !important}.col-10 {flex: 0 0 83.33333333%;max-width: 83.33333333%}.col-2 {flex: 0 0 16.66666667%;max-width: 16.66666667%;}.col-6 {flex: 0 0 50%;max-width: 50%}.no-gutters > .col, .no-gutters > [class*=col-] {padding-right: 0;padding-left: 0}h1 {font-size: 18pt;font-weight: 500;margin-bottom: .5cm}.card-title, .text-title, h1, h2, h3, h4, h5, h6 {color: #332e38}.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {font-family: inherit;font-weight: 500;line-height: 1.2}.h4, h4 {font-size: 1.2195rem}header {font-size: 10px}@page {size: A4;margin-top: 11mm;margin-bottom: 5mm;margin-left: 11.98mm;margin-right: 11.98mm}.page-header, .page-header-space {height: 10px;}.page-footer, .page-footer-pace{height: 10px;}.page-footer {position: fixed;bottom: 0;width: 100%;padding-left: 20px;/*border-top: 1px solid black; for demo *//*background: yellow; for demo */}.page-header {position: fixed;top: 0mm;width: 100%;/*border-bottom: 1px solid black; for demo *//*background: yellow; for demo */padding-left: 20px;}.page {page-break-after: always;}@page {margin: 5mm}@media print {thead {display: table-header-group;}tfoot {display: table-footer-group;}button {display: none;}body {margin: 0;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;letter-spacing: .3px;line-height: 1.6;}}</style></head><body><div class="page-header" style="z-index:1000;background: white">');

    if (this.islogo)
    mywindow.document.write('<img src="/assets/images/logo.png" width="200" height="68" alt=""  />');

    mywindow.document.write('</div><div class="page-footer" style="padding: 70px 0px 0px 0px;" >');
    if(this.islogo)
      mywindow.document.write('<div style="border-top: 1px solid black; font-size: 8px; z-index:1000;background: white">hi how are you</div>');
    mywindow.document.write('</div><table><thead><tr><td><!--place holder for the fixed-position header--><div class="page-header-space"></div></td></tr></thead><tbody><tr><td><!--*** CONTENT GOES HERE ***--><div class="page">');
    mywindow.document.write(data);
    debugger;
    mywindow.document.write('</div></td></tr></tbody><tfoot><tr><td><!--place holder for the fixed-position footer--><div class="page-footer-space"></div></td></tr></tfoot></table></body></html>');
    mywindow.print();
    mywindow.close();

    return true;
  }
javascript angular typescript
1个回答
0
投票

某些用户计算机上可能存在弹出窗口阻止程序,并且也可能存在浏览器兼容性,因为不同的浏览器可能以不同的方式处理打印功能。用它来检查是否有弹出窗口拦截器。

var mywindow = window.open('', '_blank');

    if (!mywindow) {
        alert("Popup blocker detected! Please allow popups for this site.");
        return;
    }
© www.soinside.com 2019 - 2024. All rights reserved.