mPDF font-size not working for long text in a table

zef picture zef · May 20, 2014 · Viewed 15.6k times · Source

Using mPDF to print html to pdf the font-size I set in html is not properly set in creating the pdf. In my html I have

<table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-family:myriadpro, Verdana, sans-serif; color:#111111;">
<tr>
<td align="left" style="vertical-align:top; padding:5px; font-size: 12pt;">
etc.

However mPDF scales the font-size to 9pt in the PDF. If I use 24pt it scales to 18pt. I checked and tried to change the configs and displaypreferences (NoPrintScaling) in mPDF but none of this is working.

Has anybody got a clue on how to get rid of this scaling? I don´t want to set the font-size bigger to compensate for mPDF behaviour because that will ruin my html view.

Answer

zef picture zef · May 20, 2014

mPDF uses autosizing tables and this influences, among other things, the font-size as well. When outputting tables with mPDF you need to set:

<table style="overflow: wrap">

on every table. See Auto-layout algorithm in the mPDF manual for reference.