function PrintDiv(id, rt) {
  let div = document.getElementById(id);

  html2canvas(div).then(function (canvas) {
    var myImage = canvas.toDataURL("image/png");
    var tWindow = window.open("");
    $(tWindow.document.body)
      .html(
        "<html><head><title>" +
          rt +
          "</title></head><body><img id='Image' src=" +
          myImage +
          " style='width:100%; height:85%'></img></body></html>"
      )
      .ready(function () {
        setTimeout(function () {
          tWindow.focus();
          tWindow.print();
          tWindow.close();
        }, 100);
      });
  });
}

//my button<input type="button" value="Print table" style="float:right;" class="btn btn-sm btn-info" onclick="PrintDiv('myDiv')" />
