Here is my code:
$htmls ='<html><body style="font-size:100px;"> <table style="width:100%;border-spacing: 0px; margin-top: 10px;background-color: #FF5733;font-size:100px;" > <tr> <td style="padding: 5px 8px; font-weight: bold;">TEST</td> <td style="padding: 5px 8px;"> Test1 </td> <td style="padding: 5px 8px;"> Test2 </td> </tr> </table></body></html>'; require './mpdf60/mpdf.php'; $mpdf = new mPDF('utf-8', 'A4', 1); $mpdf->SetDisplayMode('fullpage'); $mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true; $mpdf->useSubstitutions = false; $mpdf->simpleTables = true; $mpdf->packTableData = true; $mpdf->showImageErrors = true; $mpdf->list_indent_first_level = 0; $mpdf->WriteHTML($html); $fname = date('Y-m-d-h-i-s') . ".pdf"; $mpdf->Output(__DIR__ . "/pdf/" . $fname); $filePath =__DIR__ . "/pdf/" . $fname;
Output:
I need it.
How to fix it. Creating a css
file is difficult for me because I use different styles on all tags.
Advertisement
Answer
You’re using an older version of mPDF. Its current stable release is 2 major versions ahead of the version you’re using.
Your code contains a typo. Change $htmls
to $html
.
When I test your code with mPDF 8(.0.7), things work swimmingly, and this is the output I get: