css – how to Styling for printing in JavaScript


to print the contract, I want to do some parts of the table in the middle of the line and look like what you see in the picture

I did them correctly in View, but in JavaScript I want them to look like View in print.

If I put text-align: center in the style, the whole form will be centered, which I do not want. Please help

<script>

    function printDiv() {
        var divToPrint = document.querySelectorAll('.print-table');
        var htmlToPrint="" +
            '<style type="text/css">' +
            'table th, table td {' +
            'font-family:vazir;' +
            'border:1px solid #000;' +
            'padding:0.5em;' +
            '}' +
            '</style>';

        divToPrint.forEach((item) => {
            htmlToPrint += item.outerHTML;
        })
        newWin = window.open("");
        newWin.document.write(htmlToPrint);
        newWin.print();
        newWin.close();
    }

</script>

enter image description here

enter image description here



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here