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

2019-01-25 09:29发布

问题:

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.

回答1:

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.



回答2:

If anyone still got the same issue after tested with accepted answer, try this :

<table style="overflow: wrap" autosize="1">

And

$mPdf->shrink_tables_to_fit = 1;

Hope this helped as my case was solved only with these combination