-
Notifications
You must be signed in to change notification settings - Fork 0
/
erispdf.js
32 lines (29 loc) · 1.43 KB
/
erispdf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function Html2ErisPdf(data, winload = false) {
var frame1 = $('<iframe />').attr("id", "printDiv");
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>');
frameDoc.document.write('<head>');
frameDoc.document.write('<title></title>');
//If you want to use any library/css
frameDoc.document.write('<link rel="stylesheet" href="cdn/localurl">');
frameDoc.document.write('</head>');
frameDoc.document.write('<body>');
frameDoc.document.write(data);
frameDoc.document.write('</body>');
frameDoc.document.write('</html>');
frameDoc.document.close();
setTimeout(function () {
document.getElementById('printDiv').contentWindow.focus();
document.getElementById('printDiv').contentWindow.print();
// frame1.remove();
if (winload) {
window.location.reload(true);
}
}, 500);
return true;
}