Print view issue

Hi
We had an issue with the document print view if we download the document from the PDF button it works perfectly but if we use Print view it breaks the tables in the Print format style.

image

Kindly could you help us with it?

this is the custom coding for that table

.calc{ font-size: 10px; width: 100%; margin-top: 5%; } .calc td{ border: 1px solid black; } .calc th{ font-size: 14px; } #rowspan-cell{ width: 60%; } .line-3 table, .line-3 td { vertical-align: middle; line-height: 1.5; font-size:9px; text-align:center; color:black; padding:4px !important; } .ql-editor { line-height: 1.5; text-align: center !important; font-family:Arial, Helvetica, sans-serif !important; } .print-format td{ < vertical-align: middle !important;
{% for item in doc.items %}
    {% set id = frappe.get_list("Item",filters=[["Item","item_code","=",item.item_code]]) %}
    {% set it_des = frappe.get_doc('Item', id[0].name) %}
<tr>
    <td>{{loop.index}}</td>
    <td style="text-align:center">{{it_des.description}}</td>
    <td>{{item.qty}}</td>
    <td>{{item.uom}}</td>
    <td>{{"{:,.2f}".format(item.rate)}}</td>
    <td>
        <!--{% if item.discount_amount > 0 %}-->
        <!--    {{"{:,.0f}".format(item.discount_amount)}}-->
        <!--{% else %}-->
        <!--    0-->
        <!--{% endif %}-->
        0
    </td>
    <td>{{"{:,.2f}".format(item.amount)}}</td>
    <td>{{"{:,.2f}".format(item.amount*(0.15))}}</td>
    <td>{{"{:,.2f}".format(item.amount+item.amount*(0.15))}}</td>

</tr>  
{% endfor %}
SR Description اﻟوﺻف QTY اﻟﻛﻣﯾﺔ Unit اﻟوﺣدة Rate اﻟﺳﻌر Total Discount إجمالي الخصم Amount اﻟﻣﺟﻣوع Tax AM اﻟﺿرﯾﺑﺔ Total AM اﻻﺟﻣﺎﻟﻲ
<table class="calc">
    <tr>
        <td style="text-align: center !important;" class="adjust-height"><b>اﻟﻣﺟﻣوع</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>Total</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>{{doc.total}}</b></td>
        <td rowspan='6' id="rowspan-cell">{{doc.terms}}</td>
    </tr>
    <tr>
        <td style="text-align: center !important;" class="adjust-height">اﻟﺧﺻم</td>
        <td style="text-align: center !important;" class="adjust-height"><b>Discount</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>{% set disc =doc.total - doc.net_total  %}
                        {{'%0.2f'%disc}}</b></td></tr>
    <tr>
        <td style="text-align: center !important;" class="adjust-height"><b>اﻹﺟﻣﺎﻟﻲ ﺑﻌد اﻟﺧﺻم</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>Total A.D</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>{{"{:,.2f}".format(doc.net_total)}}</b></td>
    </tr>
    <tr>
        <td style="text-align: center !important;" class="adjust-height"><b>%الضريبة 15</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>VAT</b></td>
        {% for tax in doc.taxes %}
            <td style="text-align: center !important;" class="adjust-height"><b>{{"{:,.2f}".format(doc.base_total_taxes_and_charges)}}</b></td>
        {% endfor %}
    </tr>
    <tr>
        <td style="text-align: center !important;" class="adjust-height"><b>ﺧﺻم ﻟﻠﺗﻘرﯾب</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>Round OFF</b></td>
        <td  style="text-align: center !important;" class="adjust-height">
            <b>{%- if doc.rounding_adjustment != 0 -%}
                    {{doc.rounding_adjustment}}
                {% else %}
                    0
                {% endif %}</b></td>
    </tr>
    <tr>
        <td style="text-align: center !important;" class="adjust-height"><b>اﻻﺟﻣﺎﻟﻲ</b></td>
        <td style="text-align: center !important;" class="adjust-height"><b>Net Total</b></td>
        <td  style="text-align: center !important;" class="adjust-height"><b>{{"{:,.2f}".format(doc.grand_total)}}</b></td>
    </tr>
    <tr style="border: 1px solid grey">
        <td colspan="3" style="text-align: center; border-style: none !important">اﻻﺟﻣﺎﻟﻲ</td>
        {% if doc.in_words_arabic != none %}
            <th style="text-align: center !important;direction:rtl"><b>{{ doc.in_words_arabic}}</b></th>
        {% else %}
            <th style="text-align: center !important;direction:rtl"><b>{{doc.amount_in_words_arabic}}</b></th>
        {% endif %}

</tr>
<tr style="border: 1px solid grey">
    <td colspan="3" style="text-align: center; border-style: none !important"><b>Net Total</b></td>
    <th style="text-align: center !important"><b>{{ doc.in_words }}</b></th>
</tr>
</table>
<script>
    window.addEventListener('DOMContentLoaded', function () {
    var rowspanCell = document.getElementById('rowspan-cell');
    var adjustCells = document.getElementsByClassName('adjust-height');

    var rowspanHeight = rowspanCell.offsetHeight;

    Array.from(adjustCells).forEach(function (cell) {
      cell.style.height = rowspanHeight + 'px';
    });
  });
</script>

I am also a beginner… Learning erpnext… I dont know whether this will solve the problem… but If you remove the script which is at the end of html I think it will work as you need… but still need to see the full code to suggest more…

Thanks, Sir it has been resolved.

1 Like