Unable to download pdf in html2pdf

Viewed 277

I am trying to download pdf from html2pdf. Download dialog box doesn't appear and it gives error

Some data has already been output, can't send PDF file

I am trying to fetch the data from database and convert it into pdf downloadable. Here is the code

<?php   
    $content = '<html><body style=" background-color:#edeff0;
    margin:0px;padding:0px;">';
    $content .= '<p>kjhj</p>'; 
    $content .= '</body></html>';
    require_once('html2pdf/html2pdf.class.php');
    $html2pdf = new HTML2PDF('P','A4','fr');
    $html2pdf->WriteHTML($content);
    $separator = md5(time());
    $eol = PHP_EOL;
    $filename = "receipt.pdf";
    $pdfdoc = $html2pdf->Output($filename, 'D');
    header("Content-Disposition: attachment; filename=receipt.pdf");
 ?>
0 Answers
Related