0

Mpdf is generating blank white page pdf when including stylesheet, and working fine when I remove the stylesheet $mpdf->WriteHTML($stylesheet,1); But I want to include the stylesheet. Any help appreciated.

 <?php if(isset($_POST['pdf'])){ ob_clean(); flush(); /*-------------------- for genearte pdf start -----------------*/ include("mpdf/vendor/autoload.php"); include('includes/db.php'); $mpdf = new \Mpdf\Mpdf(); //$html = '<h1>Welcome</h1>'; $html = '<div class="table-responsive"> <table class="table table-hover tablesorter pdf_border"> <thead> <tr class="pdf_border"> <th class="header pdf_border">Name</th> </tr> </thead> <tbody>'; ?> <?php $sqli = "SELECT * FROM user"; $resulti = mysqli_query($connection,$sqli); while($row = mysqli_fetch_assoc($resulti)) { $html .= '<tr class="pdf_border"> <td class="pdf_border">'.$row['name'].'</td> </tr>'; } $html .= '</tbody></table>'; $path = 'pdf/'; $file_name ="webpreparations-".time().".pdf"; $stylesheet =file_get_contents('css/bootstrap.min.css'); $mpdf->WriteHTML($stylesheet,1); // $mpdf->WriteHTML($html,2); $mpdf->Output($path.$file_name, "D"); } ?> <form action="" method="post"> <input type="submit" name="pdf" class="pull-right btn btn-warning btn-large" style="margin-right:40px" value="Genarte PDF"> </form> 

and getting corrupted pdf file if I remove ob_clean(); flush();

1
  • please make your mind whether your question is about mysql or css. they have nothing in common Commented Feb 12, 2021 at 14:28

1 Answer 1

0

Add stylesheet using

$mpdf->WriteHTML('path/your stylsheet.css'), \Mpdf\HTMLParserMode::HEADER_CSS); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.