Php 如何在codeigniter中用孟加拉语生成pdf文件
我使用的是Php 如何在codeigniter中用孟加拉语生成pdf文件,php,codeigniter,Php,Codeigniter,我使用的是m_pdf它适用于英语,但不适用于孟加拉语。我已经加载了m_pdf库 请帮助任何人 这是我的控制器代码: public function download_pdf(){ $sess_info = $this->session->userdata('loggin_user'); $user_name = $sess_info->user_name; $profile_id = $this->uri->segment(3); $
m_pdf
它适用于英语,但不适用于孟加拉语。我已经加载了m_pdf
库
请帮助任何人
这是我的控制器代码:
public function download_pdf(){
$sess_info = $this->session->userdata('loggin_user');
$user_name = $sess_info->user_name;
$profile_id = $this->uri->segment(3);
$data = [];
//load the view and saved it into $html variable
$data['get_profile']=$this->Dashboard_model->get_profile($profile_id);
$html=$this->load->view('users/profile_pdf', $data, true);
//this the the PDF filename that user will get to download
$pdfFilePath = $user_name.".pdf";
$this->m_pdf->pdf->WriteHTML($html);
$this->m_pdf->pdf->Output($pdfFilePath, "D");
}
在将任何数据放入PDF之前设置UTF-8编码
$this->m_pdf->pdf->allow_charset_conversion = true;
$this->m_pdf->pdf->charset_in = 'UTF-8';
在ttf目录中下载并添加kalpurush.ttf文件,然后在控制器中
$mpdf = new \Mpdf\Mpdf([
'default_font_size' => 16,
'default_font' => 'kalpurush'
]);
$stylesheet = '<style>'.file_get_contents('assets/css/style2.css').'</style>';
$html = $this->load->view('print',[],true);
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html,2);
$mpdf->Output();
$mpdf=new\mpdf\mpdf([
“默认字体大小”=>16,
“默认字体”=>“kalpurush”
]);
$stylesheet=''.file_get_contents('assets/css/style2.css');
$html=$this->load->view('print',[],true);
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html,2);
$mpdf->Output();
然后尝试直接对HTML编码$HTML=mb\u convert\u编码($HTML,'UTF-8','UTF-8')代码>之前写入TML