URL Problem after file download via fpdf


i generate a pdf file via fpdf libary which is preparing all the data and sending it the following way:

//Send to standard output


				$this->Error('Some data has already been output, can\'t send PDF file');



				//We send to a browser

				header('Content-Type: application/pdf');


					$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');



			echo $this->buffer;

this works fine, the file is generated and the download window opens.

now my problem. after i downloaded or saved the pdf file the next click i do will creates an error. it doesn’t matter which link, yii always shows an error. when i check the error log it tells that the controller called the pdf creation (but in the adress line of the browser there is another page written). also the page i wanted to see is showed after the error output.

The error is: Cannot modify header information - headers already sent by (output started at /.../app/protected/extensions/pdf/fpdf_fpdi/fpdf.php:1026)

after the error output it is written:

HTTP/1.1 200 OK Date: Sat, 23 Apr 2011 20:23:27 GMT Server: Apache X-Powered-By: PHP/5.3.5 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Keep-Alive: timeout=15, max=98 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 207f

followed by the page i clicked.

Maybe Yii produced an error after fpdf was sending the outputput to the browser, saved the error and is showing it on the next page.

how can i avoid this? can i clean the last error? do i have to made special settings in yii before i output a file to the browser? i also tested to send the output with sendFile but with the same result.

thanks for tips or help!


I solved it. I didn’t end the Application the right way by Yii::app()->end(); after the pdf output was finished