Print Format file instance in issue occurs

Hello,
I create local packing slip doctype for one print format
HTML:

S/N ITEM CODE MRP WO. NO COLOUR SIZES Qty T/Qty {% for item in doc.items|unique(attribute='custom_item_group') %} {% if item.custom_item_group=="Mens Shirt" %} S/36
<td>M/38</td>
<td>L/40</td>
<td>XL/42</td>
<td>2XL/44</td>
<td>3XL/46</td>
{% elif item.custom_item_group=="Trouser" %}
<td>S/28</td>
<td>M/30</td>
<td>XL/34</td>
<td>2XL/36</td>
<td>3XL/40</td>
 {% endif %} {% endfor %}
{% for item in doc.items %} {{ item.idx }} {{ item.custom_color or ""}} {% for items in doc.items|unique(attribute='custom_item_group') %} {% if items.custom_item_group=="Mens Shirt" %} {% elif items.custom_item_group=="Trouser" %} {% endif %} {% endfor %} {% endfor %} Total

PREPARED BY:_________________

CHECKED BY:_________________

PACKED BY:_________________

NOTE : FOR ANY DISCREPANCY IN GOODS PLEASE CONTACT IMMEDIATELY MOB : 9999999999 / EMAIL : company@gmail.com

CSS:
.table, th, td {
border: 1px solid black;

}
.print-format td, .print-format th {
padding: 5px !important;
}
.print-format{
padding: 0px !important;
}

in print time local site result is:

And pdf result is:

But Now issue come in live pass this print formate
print result come proper:

But pdf time not proper layout come:

How to solve this issue.