Reputation: 25
While in English dompdf is supporting well, now coming to Arabic it is showing question marks instead of Arabic characters.
My code:
//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));
}
The result:
Upvotes: 1
Views: 2856
Reputation: 146603
The project Github page has a specific note (About Fonts & Character Encoding) right in the home page (emphasis mine):
PDF documents internally support the following fonts: Helvetica, Times-Roman, Courier, Zapf-Dingbats, & Symbol. These fonts only support Windows ANSI encoding. In order for a PDF to display characters that are not available in Windows ANSI you must supply an external font.
The code you've shared does not make any attempt to load an external font or use the default DejaVu family bundled in the library.
Upvotes: 1