虽然在英语中dompdf支持得很好,但现在使用阿拉伯语时它会显示问号而不是阿拉伯字符。
我的代码:
//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));
}
结果:
答案 0 :(得分:0)
项目Github页面在主页(强调我的)中有一个特定的注释(About Fonts & Character Encoding):
PDF文档内部支持以下字体:Helvetica, Times-Roman,Courier,Zapf-Dingbats,&amp;符号。这些字体只 支持Windows ANSI编码。为了显示PDF 您必须提供Windows ANSI中不可用的字符 外部字体。
您共享的代码不会尝试加载外部字体或使用库中捆绑的默认 DejaVu 系列。