I use this method to copy a DIV from my webapp to be printed in a new tab or saved to the database, like a certificate, for example (it is an automated proccess, I can't ask the user to do that): https://stackoverflow.com/a/40389924/1062933 [thanks!]
printForm(): void {
let printContents: any = document.getElementById('formTerms').innerHTML;
let w: any = window.open();
w.document.write(printContents);
w.document.write('<scr' + 'ipt type="text/javascript">' + 'window.onload = function() { window.print(); window.close(); };' + '</sc' + 'ript>');
w.document.close(); // necessary for IE >= 10
w.focus(); // necessary for IE >= 10
}
But the resulting HTML comes unformatted without the CSS it had in the main tab.
Is there a way to also copy the CSS styles used in that DIV?
I am using Angular4 and Teradata Covalent