Created
October 5, 2019 16:50
-
-
Save Maes95/4b061c8fdbbe13e4e33e793f1191106d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printElementSimple(elem){ | |
w=window.open(); | |
w.document.write($(elem).html()); | |
w.print(); | |
w.close(); | |
} | |
document.getElementById('preview-viewer').contentWindow.print() | |
function printElement(elem, style){ | |
if (document.getElementById != null){ | |
var html = '<HTML>\n<HEAD>\n'; | |
if (document.getElementsByTagName != null){ | |
var headTags = document.getElementsByTagName("head"); | |
if (headTags.length > 0) { | |
html += headTags[0].innerHTML; | |
} | |
} | |
html += "<STYLE>"+style+"</STYLE>"; | |
html += '\n</HEAD>\n<BODY>\n'; | |
var elem = elem | |
if (elem != null) html += elem.innerHTML; | |
else{ | |
alert("Error, no contents."); | |
return; | |
} | |
html += '\n</BODY>\n</HTML>'; | |
var printWin = window.open("","PrintWindow"); | |
printWin.document.open(); | |
printWin.document.write(html); | |
printWin.document.close(); | |
//printWin.print(); | |
} else alert("Browser not supported."); | |
} | |
var style = "td span, td del, td ins { word-break: break-word;} del { color: #000; background: #f88; text-decoration: none;} ins {color: #000; background: #9f9; text-decoration: none;}" | |
printElement($('.pad-top-md>.ng-star-inserted'),style); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment