Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have used dompdf to display the user information in admin of my wordpress project. While generating the PDF file it works perfectly in my local server. But in live server Unable to stream pdf: headers already sent message is displayed.

The page where pdf is generated is http://mysite.com/wp-admin/admin.php?page=certificate&id=4.

The file for this link is include(ABSPATH."wp-content/themes/ncc/certificate.php");

Here is the code I have used

<?php
require_once("dompdf/dompdf_config.inc.php");
ob_end_clean();
ob_start();
?>
<style type="text/css">
.fnt_italic { 
    font-size: 18px;
    font-style: italic;
    font-weight:bold;
    font-family:Arial, Helvetica, sans-serif;
}
.clsTd {
    font-size: 12px;
    /*font-family:"Courier New", Courier, monospace!important;*/
}
.clsBg {
    background-color:#000;
}
.clsBgGray {
    background-color:#CCCCCC;
}
.clsBgWhite {
    background-color:#FFF;
}
.clsBold {
    font-weight: bold;
}
.tbl { border:1px double #000000; }
.notes { font-size:10px; color:#999999; }
.clsDiv { padding-top: 20px; }
</style>
<div class="clsDiv">
<table align="center" cellpadding="6" cellspacing="2" width="90%" class="tbl">
  <tr>
    <td>
      <table border="0" cellpadding="6" cellspacing="2" width="90%" align="center">
         <tbody>
          <tr align="center">
            <td class="fnt_italic" colspan="2">Certificate</td>
          </tr>
          <tr align="center">
            <td colspan="2">Name</td>
          </tr>
          <tr align="center">
            <td colspan="2" class="clsTd">Email id</td>
          </tr>
         </tbody>
       </table>
     </td>
    </tr>
</table>       
</div>
<script type="text/php">
if ( isset($pdf) ) {

  $font = Font_Metrics::get_font("helvetica");
  $size = 9;
  $text_height = Font_Metrics::get_font_height($font, $size);

  $foot = $pdf->open_object();
  $w = $pdf->get_width();
  $h = $pdf->get_height();
  $y = $h - $text_height - 40;
  $pdf->close_object();
  $pdf->add_object($foot, "all");
  $color = array(0,0,255);
  $text2 = "Page: {PAGE_NUM} of {PAGE_COUNT}";
  $pdf->page_text(710, $y, $text2, $font, $size, $color);
  $text = "Text"; 
  $pdf->page_text(15, $y, $text, $font, $size, $color);
}
</script>
<?php
$data = ob_get_clean();
$old_limit = ini_set("memory_limit", "64M");
$dompdf = new DOMPDF();
$size = array(0,0,800.00,700.00);
$dompdf->load_html($data);
$dompdf->set_paper($size);
$dompdf->render();
$dompdf->stream('certificate.pdf');
?>

Can anyone help me what is the creating problem here. Thanks in advance

share|improve this question
    
Do you by any chance have WP_DEBUG turned on there? When you can get a code to work on one server, but then get headers already sent errors on another, its most often a case of debug or error messages being output before the page renders. See if turning debug or error reporting off will allow the page to render properly? –  goldenapples Jun 2 '11 at 6:20
    
Thanks goldenapples :). I checked WP_DEBUG its set to false. Can you suggest me where do I check error reporting ? Is that in server configuration or else where? Thanks again... –  user478 Jun 2 '11 at 6:46
    
This question doesn't necessarily pertain to WordPress even though it sits on a WP install. –  Brian Fegter Feb 24 '12 at 3:25
add comment

closed as off topic by toscho Jul 5 '12 at 21:15

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.