#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Barcelona
    Posts
    303
    Rep Power
    77

    TCPDF ERROR: Some data has already been output to browser, can't send PDF file


    PHP Code:
    require_once('./tcpdf/examples/lang/eng.php'); 
    require_once(
    './tcpdf/tcpdf.php'); 
    $pdf = new TCPDF(); 
    $pdf->setPrintHeader(false); 
    $pdf->setPrintFooter(false); 
    $pdf->SetFont('helvetica'''10); 
    $pdf->AddPage(); 
    $htmlcontent "<p>Hello world</p>"
    $pdf->writeHTML($htmlcontenttrue0true0); 
    $pdf->Output('minimal.pdf','I'); 
    The answer is "TCPDF ERROR: Some data has already been output to browser, can't send PDF file" as you can see in http://www.c2001.com/index.php

    I have checked that no blanks were there and zlib.output_compression in my php.ini is disabled.

    Can you advise me where the error is?

    Thanks!
    Pere
    www.casti2001.com
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    There has to be some white space being output somewhere. Reexamine all the includes. It could be nothing more than a blank line somewhere before a <?php tag.

    Comments on this post

    • Pere agrees : Thanks for solving my problem!
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Barcelona
    Posts
    303
    Rep Power
    77
    Thank you gw1500se!

    But, please, believe me I have been checking that no blanks were there. In my code above I simply had the header <!DOCTYPE HTML>, the header tag, the body tag and immediately after, in a new line, the PHP short tag <? and in the next line the TCPDF code I show in my first post.

    By reading your kind answer -to be honest, not believing you... sorry- I have removed both the tags header and body and nothing happened. Finally I removed the <!DOCTYPE HTML> and the script does what it must.

    If you did not insist in removing EVERYTHING other than de TCPDF code I would still be desperate... and a customer waiting next Monday for my finished software.

    You deserve my thousand "thankius"!!!

    Comments on this post

    • ManiacDan agrees : I like this kind of response.
    Pere
    www.casti2001.com
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    This problem is discussed extensively and hilariously here

    (It's also in the new user guide)
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Barcelona
    Posts
    303
    Rep Power
    77
    Thank you for this info!
    Pere
    www.casti2001.com
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    Kraljevo, Serbia
    Posts
    1
    Rep Power
    0

    Work on WAMP but no work on real server


    I have this problem on real server but on my WAMP (local) server all is OK. Why ?
    TCPDF ERROR: Some data has already been output to browser, can't send PDF file
  12. #7
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Originally Posted by digikv
    I have this problem on real server but on my WAMP (local) server all is OK. Why ?
    TCPDF ERROR: Some data has already been output to browser, can't send PDF file
    The answer to this question has been provided over and over again. It's in the new user guide, it's in this thread, and it's in the other threads which are linked to from this thread. If you can't figure it out from those resources, you'll have to hire someone to fix it for you.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo