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.
You could add this code inline to the <table> tag, the <tr> tag or to each <th> tag. A few options but this is the code you need: style=font-size:12px, change 12 to whatever font size suits your needs.
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size.
In HTML, you can change the size of text with the <font> tag using the size attribute. The size attribute specifies how large a font will be displayed in either relative or absolute terms.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With