首页 > 解决方案 > 如何在 CI 框架中使用 dompdf 在循环中生成 pdf。

问题描述

foreach($this->input->post('properties') as $propertyID){
    $data['property'] = $this->Property->get_property_by_id($propertyID,$this->user_id);
    $html = $this->load->view('backend/mail_template/send_bulk_property',$data,true);
    $html = $this->output->get_output();
    $this->load->library('pdf');
    $this->dompdf->loadHtml($html);
    $this->dompdf->setPaper('A4', 'portrait');
    $this->dompdf->render();
    ob_start();
    $output = $this->dompdf->output();
    file_put_contents('./uploads/'.$data['property']['slug'].'.pdf', $output);    
    ob_end_clean();
}

标签: codeigniter-3dompdf

解决方案


推荐阅读