1
I’m using the library mpdf in my project, however at the time of generating the document it is returning me a string and is not generating anything, you know what can be?
Google Chrome Developer Tools - Preview:
Google Chrome Developer Tools - Response:
Controller class:
public function get_relatorio_pdf(){
$request_body = file_get_contents('php://input');
$data = json_decode($request_body);
if (!is_logged_in() || !$this->session->has_userdata('admin')){
$this->load->view('login_view');
return;
}
$this->load->library('pdf');//carrega a biblioteca mPDF
$body = $this->pdf->get_relatorio_teste();
$mpdf = $this->pdf->load();//cria um objeto de 'pdf'
$mpdf->WriteHTML($body);
$mpdf->Output('relatorio.pdf', 'I');//mostra o pdf no navegador
return;
}
PDF.php
public function load($param=NULL){
if (file_exists('/xampp/htdocs/teste/vendor/autoload.php')) {//caminho no windows de desenvolvimento local
include_once '/xampp/htdocs/teste/vendor/autoload.php';
include_once '/xampp/htdocs/teste/vendor/mpdf/mpdf/mpdf.php';
}else if(file_exists('/var/www/html/teste/vendor/autoload.php')){//caminho no ubuntu de desenvolvimento local
include_once '/var/www/html/teste/vendor/autoload.php';
include_once '/var/www/html/teste/vendor/mpdf/mpdf/mpdf.php';
}else{//colocar caminho dos includes do servidor de producao da dirppg aqui
/*include_once '/var/www/????/vendor/autoload.php'; //descobrir o caminho de autoload.php
include_once '/var/www/????/vendor/mpdf/mpdf/mpdf.php';//descobrir o caminho de mpdf.php
*/
var_dump("Erro");
}
if ($param == NULL) {
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
}
$mpdf = new mPDF($param);
return $mpdf;
}
public function get_relatorio_teste(){
$html = '<div>Olá mundo</div>';
return $html;
}
is to be the last, I installed this week direct from using:
composer require mpdf/mpdf
in git bash– Gabriel Becher
and what does that mean?
– Gabriel Becher