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

2019-01-25 08:58发布

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.

2条回答
Juvenile、少年°
2楼-- · 2019-01-25 09:43

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.

查看更多
Explosion°爆炸
3楼-- · 2019-01-25 09:48

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

查看更多
登录 后发表回答