Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save mpdf generated file to a folder?

I am having Problem in saving pdf generated by mPDF to a specific folder. Every thing is working fine with pdf generation, Only I am not able to save it to a local folder. Can any one help me out with that?

like image 227
Afghan Host Avatar asked Sep 16 '25 10:09

Afghan Host


2 Answers

Short answer is to put the full path where you plan to save the file. Like so...

$mpdf->WriteHTML($html);
$mpdf->Output('/etc/home/JohnWayne/example/pdf/','F');
like image 115
Notoc Avatar answered Sep 19 '25 06:09

Notoc


I found the solution. This is very simple. As for as mPDF library is concerned, it does not parse the base_url(). Instead we have to work with $_SERVER['DOCUMENT_ROOT']; In my case i have done as; Open the config.php in Application/config folder and insert the following;

$config['file_path']=$_SERVER['DOCUMENT_ROOT']."my_project/file/";

Now it is a peace of cake to call the config; Here is I have done in the controller;

$this->mpdf->Output($this->config->item('file_path')."invoice/arif.pdf",'F');

The Problem is solved. Do let me know if there is any technical or logical issue with my code.

like image 21
Afghan Host Avatar answered Sep 19 '25 07:09

Afghan Host