Add a button called Print in the HTML file.
Set the onclick event for this button, as shown below.
- <div>
- <br>
- <input type="button" id="exporttopdf" value="Export to PDF" onclick="exportSelectedItemsToPdf();" style="display:none;" />
-
- <span> </span><input type="button" value="Print" id="print" style="display:none" onclick="PrintPage();" />
-
- </div>
Here is the function representing the link to that button and it gets executed, when triggered.
- function PrintPage()
- {
-
- var contents = $("#tab-5").html();
- var frame1 = $('
- <iframe />');
- frame1[0].name = "frame1";
- frame1.css({ "position": "absolute", "top": "-1000000px" });
- $("body").append(frame1);
- var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
- frameDoc.document.open();
-
- frameDoc.document.write('
- <html>
- <head>
- <title>Case Details</title>');
-
- frameDoc.document.write('
- <link href="/sites/LPMS/Style Library/LPMS/CSS/jquery-ui.css" media="print" rel="stylesheet" />');
- frameDoc.document.write('
- <link href="/sites/LPMS/Style%20Library/LPMS/CSS/tab-styles.css" media="print" rel="stylesheet" />');
- frameDoc.document.write('
- <link href="/sites/LPMS/Style%20Library/LPMS/CSS/CaseDetails.css" media="print" rel="stylesheet" />');
- frameDoc.document.write('
- <link href="https://industowers.sharepoint.com/sites/LPMS/Style%20Library/LPMS/tinymce/js/tinymce/skins/lightgray/content.min.css" media="print" rel="stylesheet" />');
- frameDoc.document.write('
- </head>
- <body>
- ');
-
-
- frameDoc.document.write(contents);
- frameDoc.document.write('
- </body>
- </html>');
- frameDoc.document.close();
- setTimeout(function () {
- window.frames["frame1"].focus();
- window.frames["frame1"].print();
- frame1.remove();
- }, 5000);
- }
Click Print button for the result.
Here is the Print popup along with the preview on the right side, which gets generated, as shown below. Map your printer, select copies to print or cancel, if you want to exit from this Print menu.