0

I am using the FPDF Library and when I try to make a PDF I'm getting the following error:

Warning: Cannot modify header information - headers already sent by (output started at-----) FPDF error: Some data has already been output, can't send PDF file

//Send to standard output
            if(ob_get_length())
                $this->Error('Some data has already been output, can\'t send PDF file');
            if(php_sapi_name()!='cli')
            {
                //We send to a browser
                header('Content-Type: application/pdf');
                if(headers_sent())
                    $this->Error('Some data has already been output, can\'t send PDF file');
                header('Content-Length: '.strlen($this->buffer));
                header('Content-Disposition: inline; filename="'.$name.'"');
                header('Cache-Control: private, max-age=0, must-revalidate');
                header('Pragma: public');
                ini_set('zlib.output_compression','0');
            }
            echo $this->buffer;
SeanWM
  • 16,789
  • 7
  • 51
  • 83

1 Answers1

1

At some point, something causes php to send data to the client.

If you can't see any reason for this (i.e. you don't send data explicitly), then look for stray text, spaces, newlines, etc. before the start of your PHP code (<?php) in the source file.

That should solve the issue.

Note: As pointed out by wh1t3h4ck5 you may also have to check your included files if the source of the error isn't in the current file. Look for recently modified files.

Community
  • 1
  • 1
Jean
  • 7,623
  • 6
  • 43
  • 58