DOMPDF: Unable to stream pdf: headers already sent

后端 未结 10 2134
夕颜
夕颜 2020-12-18 06:45

This question has been raised hundred of times in various fora; some have been solved, some not. I checked plenty of resources, but my issue could not be resolved. I am gene

相关标签:
10条回答
  • 2020-12-18 07:15

    simple solution :

    write below lines before stream, it will show where exactly new line or space is coming

    $f;
    $l;
    if(headers_sent($f,$l))
    {
        echo $f,'<br/>',$l,'<br/>';
        die('now detect line');
    }
    
    0 讨论(0)
  • 2020-12-18 07:15

    for me - solution was to encode my file to UTF-8 instead of UTF-8 BOM

    0 讨论(0)
  • 2020-12-18 07:16

    Replace line 3105 of this file: dompdf/lib/class.pdf.php

    if ( headers_sent()) {
      die("Unable to stream pdf: headers already sent");
    }
    

    With

    $output = ob_get_clean();
    if ( headers_sent()) {
        echo $output; }
    

    Then in the file that is generating the pdf output e.g if you were outputting from a Joomla Component components/com_joomlacomponent/views/yourpdfdir/tmpl/default.php Enter immediately after the opening php tag

    <?php
    ob_start();
    
    0 讨论(0)
  • 2020-12-18 07:22

    In my case the problem was solved by setting $_dompdf_show_warnings to false in dompdf_config_inc.php

    0 讨论(0)
  • 2020-12-18 07:26

    I had this issue, with no apparent output when viewing the source. The problem for me was that I had flushed the output, even though there was none except the headers, and that blocked streaming the output giving the "headers already sent" message. Which was true. My fix was to remove the flush() and ob_flush() statements, and the streaming output then worked.

    0 讨论(0)
  • 2020-12-18 07:26

    i have the same problem, and i solved this problem with add this code in the top file :

    ob_start();
    

    Good luck dude!

    0 讨论(0)
提交回复
热议问题