开发者

error reading pdf file generated using dompdf

I'm trying to generate a table from html to pdf using dompdf, but I'm getting a file corrupted error when I open it on foxit reader or adobe reader, Sumatra can open the file that dompdf generates without problems

 <table border="1">
            <tr>
                <th>Name</th>
                <th>Course</th>
            </tr>
            <?php   
            foreach($select as $s){     
            ?>
            <tr>
                <td><?php echo $s->strName; ?></td>
                <td><?php echo $s->strCourse; ?></td>
            </tr>       
   开发者_开发技巧         <?php } ?>

 </table>

Here's the file which generates the pdf. The output of the code above is just stored into the session, and this file just extract its contents:

require_once('../classes/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();


$data = $_SESSION['view'];

ob_start();
?>

<!--css-->


<?php
$subj = $_SESSION['view']['bi'];

echo $subj.'<hr/>';

foreach($data as $d){


        echo $d.'<br/>';

}

$print = ob_get_contents(); 
ob_end_flush();

$tym = date('g:i s');
$filename = 'print '.$subj. $tym;
$dompdf->load_html($print);

    $dompdf->render();
    $dompdf->stream($filename. ".pdf", array("Attachment" => 0));

How do I determine the error for this one.


I had this exact same problem. The solution I came up with was to simply upgrade to DOMPDF 0.6.0 beta 2. I tested the generated PDF with Evince (Linux), Acrobat Reader and the native viewer (Mac) and Adobe Reader again on Windows. All work perfectly well.

Updgrading is pretty easy, however for me (as my config options are the same as default), I commented out everything in dompdf_config.custom.inc.php and left things at their defaults, which works for most cases.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜