我想基于由 Codeigniter 生成的一个视图创建一个 pdf。然而,这个视图有很多样式元素,以及与之关联的媒体查询,所以渲染的 pdf 与所需的最终文档完全不对应。
实现这一目标的最佳方法是什么?现在我正在使用 mPDF。无论如何都要拍摄视图的快照,然后用它生成一个 pdf,以便相关的样式在文档上正确呈现?
现在我的代码看起来像这样
public function generatePDF()
{
$this->session_expire();
$this->load->helper('url');
$user_id=$this->session->userdata('user_id');
$this->user_model=$this->db_interface->db_get_user($user_id);
// $this->load->helper('url');
//echo('error aki <br />');
$data['user'] = $this->user_model;
$data['objective'] = $this->db_interface->db_get_objectives($this->user_model->get_id());
$data['list_work'] = $this->db_interface->db_get_list_work_experience($this->user_model->get_id());
$data['list_education'] = $this->db_interface->db_get_list_education($this->user_model->get_id());
$data['list_skills'] = $this->db_interface->db_get_skills($this->user_model->get_id());
$data['list_personal'] = $this->db_interface->db_get_personal_skills($this->user_model->get_id());
$data['list_links'] = $this->db_interface->get_user_links($this->user_model->get_id());
$html = $this->load->view('display_user',$data,TRUE);
//$html = $this->load->view('display_user',$data,TRUE);
// $this->load->view('display_user', $html);
$this->mpdf->WriteHTML($html);
$this->mpdf->Output();
}
提前致谢