vendredi 26 avril 2019

How to print a div with the css of the page its contained in?

I have included the links to the css files in the scripts and those links work. which i checked through console log. How do include the css in the printed file.

I have tried using media="print" on css links on the head of the page.

 <script>
        function printDiv() {
            var content = document.getElementById('invoice').innerHTML;
            var mywindow = window.open('', 'Print', 'height=600,width=800');
            var bootstrap = '';
            console.log(bootstrap);
            var fontAwsome = '';
            var icon = '';
            var skin = '';
            var adminLite = '';
            mywindow.document.write("<!DOCTYPE html><html lang=\"en\"><head>"+
                "    <meta charset=\"utf-8\"><title>Print</title> <link rel=\"stylesheet\" href=\""+bootstrap+"\" media=\"print\">" +
                "    <link rel=\"stylesheet\" href=\""+fontAwsome+"\" media=\"print\">" +
                "    <link rel=\"stylesheet\" href=\""+icon+"\" media=\"print\">" +
                "    <link rel=\"stylesheet\" href=\""+skin+"\" media=\"print\">" +
                "    <link rel=\"stylesheet\" href=\""+adminLite+"\" media=\"print\"></head><body >"+content+"</body></html>");
            mywindow.document.close();
            mywindow.focus()
            mywindow.print();
            mywindow.close();
            return true;
        }
    </script>



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2DDgPeN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire