Error generating PDF report with mpdf60

Asked

Viewed 555 times

1

For a few days now I’m trying to generate a PDF report with PHP, I found several examples on the internet and all gives the same error, below I put the example code and the error print.

My Xampp server, is using PHP version 7 and the library to generate PDF is mpdf60.

<?php 
 include("mpdf60/mpdf.php");

 $html = "
 <fieldset>
 <h1>Teste de relatório</h1>
 <div class='creditos'>
 <p>Relatório pdf</p>
 </div>
 ";

 $mpdf=new mPDF(); 
 $mpdf->SetDisplayMode('fullpage');
// $css = file_get_contents("css/estilo.css");
 $mpdf->WriteHTML($css,1);
 $mpdf->WriteHTML($html);
 $mpdf->Output();

 exit;

 ?>

See the error output:

inserir a descrição da imagem aqui

Several libraries generate this error. If anyone can suggest another option. My project is simple does not use any framework.

  • Thank you very much Everson for editing my question, improved a lot. But as for my question, you can help me?

  • 1

    Why did you comment on the attribution in the $css variable?

  • I commented to see if that was what was generating some error. You killed the riddle, that was what was generating the error. Thank you very much

  • If the error stopped appearing , mark as answered your question , to facilitate the search for the solution of others who are with the same doubt.

1 answer

3


Remove the comment from the $css variable

 $mpdf=new mPDF(); 
 $mpdf->SetDisplayMode('fullpage');
 $css = file_get_contents("css/estilo.css");
 $mpdf->WriteHTML($css,1);
 $mpdf->WriteHTML($html);
 $mpdf->Output();
  • That’s right, it worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.