0

I'm using mPDF to create a pdf from html. Right now I'm getting the error "Warning: Cannot modify header information - headers already sent in". This is because I show some html (just site template) before I generate the pdf. My site is loaded like this: 1. site header 2. page display 3. pdf download

So now I'm looking for a way to remove the output buffer with php so I can create a valid pdf. Does anyone know how to do this? I've tried:

    echo "<div class='well'><pre>";
    print_r($output);
    echo "</pre></div>";
    /* GENERATE HTML FOR PDF */
    flush();
    ob_flush();
    ob_clean();
    $html = "<img src=\"".basepath."template/img/logoFull.png\" />";
    $pdf    = new mPDF();
    $pdf->WriteHTML($html);
    $pdf->Output('MyPDF.pdf', 'D');

This is not the full script, but I think it's enough to understand my problem.

1 Answers1

0

You can put the code which generates the PDF in a separate file and load it inside your html page using inline frames. This should solve the headers all ready sent warning..

Jay Bhatt
  • 5,601
  • 5
  • 40
  • 62