Jump to content

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


ayin
 Share

Recommended Posts

Hello,

 

I read around this error and it is said that PHP is writing some error messagens before creating the PDF, thus this error message on the resulting webpage:

 

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

 

 

 

My question is how can one force the presentation of the errors/"output to browser" that have been sent?

I know that "echo" works but "error_reporting(E_ALL);" doesn't work.

 

 

link to the post that I read:

https://www.prestashop.com/forums/topic/207872-tcpdf-error-some-data-has-already-been-output-to-browser-cant-send-pdf-file/?p=1081545

 

 

thanks

Share this post


Link to post
Share on other sites

I did another test in TCPPDF.php and resulted in:

 

"Warning: Cannot modify header information - headers already sent by (output started at /home/abc/public_html/override/classes/Product.php:1) in /home/abc/public_html/classes/Tools.php on line 143"

 

Does this mean that my Product.php override has errors?

 

The override ought to be very simple:

<?php  Class Product extends ProductCore {
  
		/** Ayin - 2014_10_09 - New product quantity fields */
		public $quantityPack;
		public $quantityBox;

		/** Ayin - 2014_10_09 - New constructors */
		public function __construct($id_product = null
									, $full = false
									, $id_lang = null
									, $id_shop = null
									, Context $context = null)     
		{
			self::$definition['fields']['quantityPack'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId');
			self::$definition['fields']['quantityBox'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId');
																
			/** Parent code */
			parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
		} 
		

	public function getAdjacentProducts()
	{

		//get the current position in the product's default category
		$position  = Db::getInstance()->getValue('SELECT position
													FROM '._DB_PREFIX_.'category_product 
													WHERE id_product = ' . (int)$this->id . ' 
														AND id_category = ' . (int)$this->id_category_default);

		// var_dump($position);
		// get products that are before and after
		
		$previous = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT cp.id_product, pl.link_rewrite, cp.position, pl.name
			FROM '._DB_PREFIX_.'category_product cp
				LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (cp.id_product = pl.id_product)
				LEFT JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product)
			WHERE p.id_category_default = '.(int)$this->id_category_default.' 
				AND (cp.position < '. (int)($position ) .' ) 
				AND cp.id_category = ' . (int)$this->id_category_default .' 
				AND pl.id_lang = '.(Context::getContext()->language->id).'
			ORDER BY cp.position DESC');

		$next = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT cp.id_product, pl.link_rewrite, cp.position, pl.name
			FROM '._DB_PREFIX_.'category_product cp
			LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (cp.id_product = pl.id_product)
			LEFT JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product)
			WHERE p.id_category_default = '.(int)$this->id_category_default.' 
				AND (cp.position > '. (int)($position ) .' ) 
				AND cp.id_category = ' . (int)$this->id_category_default .' 
				AND pl.id_lang = '.(Context::getContext()->language->id).'
			ORDER BY cp.position ASC');

		return array('previous' => $previous, 'next' => $next);
	}
}
?> 

Share this post


Link to post
Share on other sites

Maybe there's a new line in the file Product.php after the php closing tag (yes in fact there's a space "?>_")

Remove the php closing tag to see if that's what causing the problem

 

More info here

 

Hi there,

 

my debug echo says:

 

"Headers already sent in on line 0 TCPDF ERROR: Some data has already been output to browser, can't send PDF file"

 

Now i have to check all my php files right? Or is better to upload original files and make changes as needed?

 

EDIT: SOLVED. I delete my testing echo and it worked.

Thanks for you help!

Edited by ayin (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More