Issue
I have an web app while in some pages I need to make a printer to print the page but I have a side bar and the rest ist the page for a component, how it is possible to not print the sidebar only this component, I have used in TS this code.
print() {
window.print();
}
Html code starts from this one.
div class="container">
//Here I have all the HTML source
</div>
Solution
first of all assign an id to that component, then:
const printContent = document.getElementById("componentID");
const WindowPrt = window.open('', '', 'left=0,top=0,width=900,height=900,toolbar=0,scrollbars=0,status=0');
WindowPrt.document.write(printContent.innerHTML);
WindowPrt.document.close();
WindowPrt.focus();
WindowPrt.print();
WindowPrt.close();
Answered By - Mohd Tabish Baig
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.