首页 > 解决方案 > 如何使用 dompdf 在 codeigniter 中查看 pdf 文件?

问题描述

我不知道如何查看 pdf 文件。它会自动下载而不是在浏览器中查看。

这是我的代码

public function index(){
    $data_user['users'] = $this->db->get('tbl_client')->result();
    $this->load->view('Dashboard/Print/user_list', $data_user);
    $html = $this->output->get_output();
    $this->load->library('pdf');
    $this->dompdf->loadHtml($html);
    $this->dompdf->setPaper('A4', 'landscape');
    $this->dompdf->render();
    $this->dompdf->stream("mypdf.pdf");
}


SOLVED! With the answer below..

如果仍然面临这个问题。确保您没有使用任何下载管理器。

标签: phpcodeigniterpdfdompdf

解决方案


希望这可以帮助

 $this->dompdf->stream("mypdf.pdf", array("Attachment" => 0));
 exit(0);

推荐阅读