Как я могу распечатать HTML-элемент в его оригинальном стиле? ⇐ Jquery
-
Anonymous
Как я могу распечатать HTML-элемент в его оригинальном стиле?
I am trying to print HTML element using window.print(); but the html is viewed without the original style. how can I fix it?
printInvoice() { var mywindow = window.open("", "PRINT"); mywindow.document.write(""); mywindow.document.write(""); mywindow.document.write($("#html2pdf")[0].outerHTML); mywindow.document.write(""); mywindow.document.close(); mywindow.focus(); mywindow.print(); mywindow.close(); return true; } css:
@media print { #invoice { padding: 30px; } .invoice { position: relative; background-color: #fff; min-height: 680px; padding: 15px; } .invoice header { padding: 10px 0; margin-bottom: 20px; border-bottom: 1px solid #3989c6; } }
Источник: https://stackoverflow.com/questions/578 ... inal-style
I am trying to print HTML element using window.print(); but the html is viewed without the original style. how can I fix it?
printInvoice() { var mywindow = window.open("", "PRINT"); mywindow.document.write(""); mywindow.document.write(""); mywindow.document.write($("#html2pdf")[0].outerHTML); mywindow.document.write(""); mywindow.document.close(); mywindow.focus(); mywindow.print(); mywindow.close(); return true; } css:
@media print { #invoice { padding: 30px; } .invoice { position: relative; background-color: #fff; min-height: 680px; padding: 15px; } .invoice header { padding: 10px 0; margin-bottom: 20px; border-bottom: 1px solid #3989c6; } }
Источник: https://stackoverflow.com/questions/578 ... inal-style
Мобильная версия