Reputation: 93
i have a web project. In my project, i would like to give button to export file to pdf. i'm using bootstrap & codeigniter.
can anyone give example for export file to pdf in codeigniter ?
Upvotes: 0
Views: 3532
Reputation: 2716
Found this while trying to do the same. https://davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter/
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);
Don't forget to add the .pdf extension to $name
Upvotes: 1
Reputation: 345
I am using TCPDF to generate pdf files in codeigniter. check this out.TCPDF examples
Upvotes: 0