2016-09-26 56 views
1

我使用HTML實體下面的循環如何使用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.' 

' $ PDF->的WriteHTML($ invoice_original);

我想在mpdf table中顯示錶格行,但沒有顯示。 謝謝。

回答

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. 

這就是所有!