You are here:Home»KB»Programming»PHP»mPDF - Renders tables and fonts smaller than in the supplied template
Tuesday, 12 December 2017 10:33

mPDF - Renders tables and fonts smaller than in the supplied template

Written by

When using mPDF to generate a PDF from a template it renders one or more tables and the fonts within them smaller than what they are in the template.

Cause

Look at the code below:

<!-- Invoice details -->
<td valign="top" align="right" width="200">
    <table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse;">
        <tr>
            <td valign="top" width="90%" align="right"></td>
            <td align="top" class="olotd5" width="200">
                <table width="180" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
                    <tr>
                        <td>
                            <b>{t}Invoice ID{/t} - </b>{$invoice_details.invoice_id}<br>
                            <b>{t}Status{/t} - </b>{$workorder_details.status}<br>
                            <b>{t}Date{/t} - </b>{$invoice_details.date|date_format:$date_format} <br>
                            <b>{t}Due Date{/t} - </b>{$invoice_details.due_date|date_format:$date_format}<br>
                            <b>{t}Work Order{/t} - </b>{$invoice_details.workorder_id}<br>
                            <b>{t}Technician{/t} - </b>{$employee_details.display_name}<br>                                        
                            <b>{t}Credit Terms{/t} - </b>{$customer_details.credit_terms}<br>                                       
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</td>

 and you can see this line.

<td valign="top" width="90%" align="right"></td>

mPDF cannot handle this empty cells with sizing statements.

Solution

I removed this line and then the template was rendered correctly.

Read 731 times