php - CodeIgniter调用第三方类库TCPDF?
PHPz
PHPz 2017-04-11 09:05:06
0
0
379

最近刚开始使用CI,项目中需要抽取html文本内容打印成pdf,于是找到TCPDF这个类库。
看过tcpdf的文档和demo,可以通过浏览器运行php文件生成pdf。因为一直做的前端,没怎么碰过php和ci,还是不知道在ci应该怎么调用tcpdf,想实现点击打印按钮就运行tcpdf的php文件。
我应该怎么做,有没有类似的解答可以发个网址给我看看?

public function printPDF() {
        $this->load->library('Pdf');

        $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

        if (@file_exists(dirname(__FILE__).'/lang/chi.php')) {
        require_once(dirname(__FILE__).'/lang/chi.php');
        $pdf->setLanguageArray($l);
        }
        // add a page
        $pdf->AddPage();

        // set font
        $pdf->SetFont('helvetica', 'B', 20);

        // create some HTML content
        /*$html = $this->input->post("result");
        $html = "<h1>hello</h1>";*/
        $data[] = '';
        ob_start();
        $html = $this->load->view('blue/production/plan/printPDF.php', $data, TRUE);
        ob_get_contents(void);    

        // set core font
        $pdf->SetFont('helvetica', '', 10);

        // output the HTML content
        $pdf->writeHTML($html, true, 0, true, true);

        //Close and output PDF document
        $pdf->Output('example_039.pdf', 'I');
        }

在controller加载视图为$html,跳转显示Unable to load the requested file: blue/production/plan/printPDF.php

PHPz
PHPz

学习是最好的投资!

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!