使用 codeigniter & 导出为 pdf引导程序 [英] export to pdf using codeigniter & bootstrap
问题描述
我有一个网络项目.在我的项目中,我想给按钮将文件导出为 pdf.我正在使用引导程序 &代码点火器.
i have a web project. In my project, i would like to give button to export file to pdf. i'm using bootstrap & codeigniter.
谁能举个例子在codeigniter中将文件导出为pdf?
can anyone give example for export file to pdf in codeigniter ?
推荐答案
在尝试执行相同操作时发现此问题.https://davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter/
Found this while trying to do the same. https://davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter/
代替页面上使用的 redirect()
函数,您可以使用下面的代码强制下载.请注意,redirect()
只会在某些浏览器(如 chrome)中打开文件.
In place of redirect()
function used on the page, you can use the code below to force download. Note that redirect()
will only open the file in some browsers like chrome.
$this->load->helper('download');
$data = file_get_contents(base_url("downloads/reports/$filename.pdf")); // Read the file's contents
$name = 'mynewfile.pdf';
force_download($name, $data);
不要忘记将 .pdf 扩展名添加到 $name
Don't forget to add the .pdf extension to $name
这篇关于使用 codeigniter & 导出为 pdf引导程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!