douhuan9289 2016-09-11 08:34
浏览 29

codeigniter和tcpdf返回空白页面

I'd like to have a page be exported as PDF in codeIgniter. I managed to install the TCPDF library following the instructions from: TCPDF Integration and now my controller looks like:

class Mycontroller extends CI_Controller {

    public function __construct(){

            parent::__construct();
            $this->load->library("Pdf");
    }

    //make pdf
    public function pdf(){

        $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
        $pdf->SetCreator(PDF_CREATOR);
        // Add a page
        $pdf->AddPage();
        $html = "<h1>Test Page</h1>";
        $pdf->writeHTML($html, true, false, true, false, '');
        $pdf->Output('output.pdf', 'I');
    }
}

Then, I have a link in another page as:

<td><a href="<?php echo base_url(); ?>index.php/myController/pdf">Export As Pdf</a></td>

and when I click on it, I get a blank pdf. The contents of the page are not there.

Any help is greatly appreciated. Thank you!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题