function getPDF() {
  var html = String($("#previewHTML").html()).replace(
    /(<img\b[^<>]*[^<>\/])>/gi,
    "$1 />"
  );
  var htmlstr =
    '<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body>' +
    html +
    "</body></html>";
  shah.getPDF(htmlstr);
}

function printCommand() {
  var $printTarget =
    typeof getActivePreviewHTML == "function"
      ? getActivePreviewHTML()
      : $("#previewHTML").first();
  var printHTML = $.trim($printTarget.html());

  if (printHTML == "") {
    window.print();
    return;
  }

  var iframe = document.createElement("iframe");
  iframe.setAttribute("title", "Print Preview");
  iframe.style.position = "fixed";
  iframe.style.right = "0";
  iframe.style.bottom = "0";
  iframe.style.width = "0";
  iframe.style.height = "0";
  iframe.style.border = "0";
  iframe.style.visibility = "hidden";
  document.body.appendChild(iframe);

  var iframeDoc = iframe.contentWindow.document;
  iframeDoc.open();
  iframeDoc.write(
    '<!doctype html><html><head><meta charset="utf-8">' +
      '<link rel="stylesheet" type="text/css" href="style/googlewebfont.css">' +
      '<link rel="stylesheet" type="text/css" href="style/style1.css">' +
      '<link rel="stylesheet" type="text/css" href="style/style2.css">' +
      '<link rel="stylesheet" type="text/css" href="style/print.css">' +
      "<style>@page{margin:8mm;}body{background:#fff;margin:0;}#previewHTML{height:auto!important;overflow:visible!important;box-shadow:none!important;border:0!important;}</style>" +
      '</head><body><div id="previewHTML">' +
      printHTML +
      "</div></body></html>"
  );
  iframeDoc.close();

  setTimeout(function () {
    iframe.contentWindow.focus();
    iframe.contentWindow.print();

    setTimeout(function () {
      document.body.removeChild(iframe);
    }, 1000);
  }, 300);
}

window.addEventListener("load", function () {
  var studentVersion = document.getElementById("student-version");
  if (studentVersion) {
    studentVersion.checked = false;
  }
});
