下载PDF文件,而不是使用CodeIgniter进行显示 [英] Download a PDF file instead of displaying it with CodeIgniter

查看:80
本文介绍了下载PDF文件,而不是使用CodeIgniter进行显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CodeIgniter和 R& OS pdf类生成PDF文件. 但是现在的问题是,pdf显示在浏览器中. 相反,我希望将其下载. 这是我的代码:

I am generating PDF file using CodeIgniter and R&OS pdf class. But now the problem is that the pdf is displayed to the browser. I instead want it to be downloaded. Here is my code :

$this->load->library('cezpdf');

        $data['users'] = $this->user->get_all_ayant_droits();

        foreach($data['users'] as $user) {
            $db_data[] = array('name' => $user->nom, 'department' => $user->Department, 'status' => $user->Status);
        }

        $col_names = array(
            'name' => 'Noms et Prenoms',
            'department' => 'Département',
            'status' => 'Status'
        );

        $this->cezpdf->ezTable($db_data, $col_names, 'Ayant droit Base Loisirs de Kribi', array('width'=>550));
        $this->cezpdf->ezStream();  

此控制器发送文件下载缺少什么?

What is missing for this controller to send the file to download ?

推荐答案

您可以将参数传递给函数ezStream

You can pass the argument to the function ezStream

$this->cezpdf->ezStream(array $options);

$options 'compress' => 0/1启用压缩.对于压缩级别,请在第一点使用$this->options['compression'] =.默认值:1 'download' => 0/1显示嵌入式(在浏览器中)或下载.默认值:0

$options 'compress' => 0/1 to enable compression. For compression level please use $this->options['compression'] = at the very first point. Default: 1 'download' => 0/1 to display inline (in browser) or as download. Default: 0

这篇关于下载PDF文件,而不是使用CodeIgniter进行显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆