2016-12-14 145 views
0

雖然在英語dompdf支持很好,現在來到阿拉伯語,它顯示問號而不是阿拉伯字符。dompdf顯示quesetion標記而不是阿拉伯字符

我的代碼:

//get weekly report of users 

public function pdf_content3() 
{ 
    require_once("application/libraries/Dompdf/dompdf_config.inc.php"); 
    spl_autoload_register('DOMPDF_autoload'); 
    date_default_timezone_set('Asia/kolkata'); 

     $tym = date('g:i s'); 
     $filename = 'order_list'.$tym; 

$st_date = $this->input->post('start_date'); 
$ed_date = $this->input->post('end_date'); 

$date = date_create($st_date); 
$date2 = date_create($ed_date); 
$date3 = date_format($date,"Y-m-d"); 
$date4 = date_format($date2,"Y-m-d"); 

if($this->verify_min_level(9)){ 

$this->data['orders_list'] = $this->business_orders_m->get_pdf_data($date3,$date4); 

$html="<html><body>"; 

if(sizeof($this->data['orders_list']) > 0){ 

$html.="<h1 style='text-align:center'>BUSINESS USER ORDER DETAILS</h1><br><br><table style = 'border: 1px solid black;text-align:center;margin:0px auto;border-spacing: 0.5rem;border-collapse: collapse;'><thead> 
<tr><th style = 'border: 1px solid black;padding:10px'>Id No</th> 
<th style = 'border: 1px solid black;padding:10px'>User Name</th> 
<th style = 'border: 1px solid black;padding:10px'>Order Id</th> 
<th style = 'border: 1px solid black;padding:10px'>Date</th> 
<th style = 'border: 1px solid black;padding:10px'>From</th> 
<th style = 'border: 1px solid black;padding:10px'>To</th> 
<th style = 'border: 1px solid black;padding:10px'>Status</th> 
</tr> 
</thead> 
<tbody>"; 

$i = 1; 

foreach($this->data['orders_list'] as $date_search){ 

$status = ''; 
if($date_search->order_status == 0){ 
$status = 'Pending';  
}else{ 
$status = 'Completed'; 
} 

      $html.="<tr><td style = 'border: 1px solid black;padding:10px'>".$i."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$date_search->username."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$date_search->order_id."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$date_search->date."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$date_search->pickup_address."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$date_search->drop_address."</td> 
      <td style = 'border: 1px solid black;padding:10px'>".$status."</td></tr>"; 

      $i++; 

} 

$html.="</tbody>"; 
$html.="</table>"; 
}else{ 
    $html.= '<p><h1 style="text-align:center;color:red;">NO DATA AVAILABLE</h1></p>'; 
} 

$html.="</body></html>"; 
$this->pdf_create($html,$filename); 

     }else{ 
      redirect(LOGIN_PAGE); 
     } 
} 

public function pdf_create($html,$filename,$stream = TRUE) 
{ 
$dompdf = new DOMPDF(); 
$dompdf->load_html($html); 
$dompdf->render(); 
$dompdf->stream($filename.".pdf",array('Attachment'=>0)); 
} 

結果:

enter image description here

+0

也許你的字體文件不支持阿拉伯字母? – Justinas

+0

那麼如何過來它有什麼想法? –

+0

https://github.com/dompdf/dompdf#setting-options – Justinas

回答

0

項目Github上頁都有一個特定的音符(About Fonts & Character Encoding)就在主頁(重點煤礦):

PDF文檔內部支持以下字體:Helvetica, Times-Roman,Courier,Zapf-Dingbats,&符號。這些字體只有 支持Windows ANSI編碼。爲了使PDF 能夠顯示 在Windows ANSI中不可用的字符,您必須提供 外部字體

你分享不作任何試圖加載外部字體,或使用默認幻覺記憶家庭在圖書館綁定的代碼。