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()
- {
- // $("#tab-5").printThis();
- 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();
- //Create a new HTML document.
- frameDoc.document.write('
- <html>
- <head>
- <title>Case Details</title>');
- //Append the external CSS file.
- 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>
- ');
- //Append the DIV contents.
- 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);
- }


Manav PandyaPosted May 13, 2017, 12:50 AM
Nice share sir ...........