php - Cannot read pdf generated through dompdf in chrome -
i'm testing dompdf. , found out i'm generating can't red chrome. tried open sumatra pdf reader, , opened. tried opening random pdf file ebooks in chrome , red it. there wrong code chrome wasn't able read it:
<?php require_once("dompdf/dompdf_config.inc.php"); $dompdf = new dompdf(); $d_r = array(array('name'=>'ab', 'course'=>'bsit'), array('name'=>'yoh', 'course'=>'bscs')); ob_start(); put_table($d_r); file_put_contents('sample.html', ob_get_contents()); generate_pdf('sample.html'); function put_table($raw_data){ ?> <table border="1"> <tr> <th>name</th> <th>course</th> </tr> <?php foreach($raw_data $data){ ?> <tr> <td><?php echo $data['name']; ?></td> <td><?php echo $data['course']; ?></td> </tr> <?php } ?> </table> <?php } function generate_pdf($filename){ global $dompdf; $dompdf->load_html(file_get_contents($filename)); $dompdf->render(); $dompdf->stream($filename. ".pdf"); } ?>
the pdf may have been rendered correctly but, depending on server configuration, non-pdf content may have been included in pdf source. pdf readers more lenient others , discard non-pdf content. easiest way check open pdf in text editor , things strings of html text.
if that's not problem, see pdf itself.
Comments
Post a Comment