如何使用codeigniter在mpdf中显示html实体?

时间:2016-09-26 04:29:59

标签: php codeigniter mpdf

我正在为html实体使用以下循环

for($i=0;$i<$service_count;$i++)
    {
        $services[$i]['serviceName']=$service_result[$i]['service_name'];
        $services[$i]['serviceId']=$service_result[$i]['services_id'];
        $services[$i]['serviceDesc']=$service_result[$i]['service_description'];
        $services[$i]['serviceAmt']=$serviceAmt[$i];
        $services[$i]['taxAmt']=$taxAmtarr[$i];
        $services[$i]['taxId']=$taxIdarr[$i];
        $tableRow='<tr>
                    <td style="text-align:center">'.$services[$i]['serviceName'].'</td>
                    <td style="text-align:center">'.$services[$i]['serviceDesc'].'</td>
                    <td style="text-align:right">'.$services[$i]['taxAmt'].'</td>
                    </tr>';

    }
 $test=htmlspecialchars($tableRow);

我的mpdf代码是

$invoice_original.='<table border="1" style="width:950px; border-collapse:collapse" cellpadding="15">
<tr style="background-color:#bfbfbf; ">
    <th style="text-align:center;color:#000066;">Particulars</th>
    <th style="text-align:center; color:#000066;">Description</th>
    <th style="text-align:center; color:#000066;">Amount(Rs)</th>
</tr>
'.$test.'

&#39;     $ PDF-&GT;的WriteHTML($ invoice_original);

我想在mpdf表中显示表行。但是没有显示任何内容。 谢谢。

1 个答案:

答案 0 :(得分:0)

你走了:

$mpdf = new \mPDF('utf-8','A4');

$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1;  // Use values in classes/ucdn.php  1 = LATIN
$mpdf->autoVietnamese = true;
$mpdf->autoArabic = true;
$mpdf->autoLangToFont = true;

$mpdf->SetMargins(null,null,15);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader('<div style="text-align:right">B I R A</div>');
$mpdf->setFooter(' | www.bira.com | {PAGENO}');

$mpdf->WriteHTML($pdf_style.$pdf_page);

$mpdf->Output();

身体应该是:

$pdf_style = '<style>write all of your styles</style>';
$pdf_page = '<table><table>'; // write all of your html markup here.

多数人都是!!!