Welcome Guest, Not a member yet? Register   Sign In
mpdf in models
#1

(This post was last modified: 07-23-2024, 12:02 AM by virtualgadjo.)

Hi,
funny enough, last year i made a tool with a 2023 beginning ci4 release in which i used mpdf a lot in models, worked like a charm
now i'm working on anothe tool with 2024 beginning release and if i do exactly the same thing in a model, that kind of thing
PHP Code:
$mpdf = new Mpdf(['mode' => 'utf-8']);
$mpdf->WriteHTML($html);
$this->response->setHeader("Content-Type""application/pdf");
$mpdf->OutputFile('./assets/files/' $filename); 
i get an error
You must set the database table to be used with your query
of course i have the necessay use \Mpdf\Mpdf; and two requests in the method, if i comment the mpdf part, everything works fine as, if i remember well model are made to deal with data... and files
just something more, if i put exactly the same code in the controller, everything goes well, the file is created and my queies in the model work fin too, only little caveat, even if after the mpdf code my controller method ends with a return view, it returns... an empty pdf to the browser completely ignoring my return view statement

so i wonder, what went wrong within a year Smile

eager to have your insights about all this

have a nice day

Hi again,

found out by myself, it does'nt like, at all... this line
PHP Code:
$this->response->setHeader("Content-Type""application/pdf"); 

commenting this line CI doesn't ask me for a datatable anymore... and it works fine in a model as in a librairy

thanks for those who took time to read my poor english Smile
have a nice day
Reply
#2

What happens if you assign it a database table name?

Did you try that?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB