skip to Main Content

When i am going to clicking print button print dialog box is working fine with my side, but some users are complaining they are not getting print dailog after clicking print button into production site, i have check from my side locally and production but both side working fine not able to find any issue from my side, please suggest.

Below is my html

enter image description here

below is my angular component methods on button click

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

 Popup(data) {
    debugger;
    var mywindow = window;
    mywindow.print();
    mywindow.close();

    return true;
  }

2

Answers


  1. Chosen as BEST ANSWER

    In Lastest version of chrome browser: working fine with 126 version chrome and not working 127 and greater than chrome version.

    So I have removed below than working fine to me.

    mywindow.close();
    

  2. There can be popup blockers on some users computer and also there is a possibility of Browser Compatibility as different browsers may handle the print functionality differently. use this to check if there is popup blocker.

    var mywindow = window.open('', '_blank');
    
        if (!mywindow) {
            alert("Popup blocker detected! Please allow popups for this site.");
            return;
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search