2012-03-21 47 views
0

我得到以下警告時,試圖從遠程服務器查看list_of_holidays.pdf PDF文件:CakePHP的tcpd的錯誤:有些數據已經被輸出到瀏覽器,無法發送遠程服務器

Warning (2): Cannot modify header information - headers already sent by (output started  
at /home/aquinto1/app/views/helpers/flash.php:155) [APP/vendors/tcpdf/tcpdf.php, line 8541] 
TCPDF ERROR: Some data has already been output to browser, can't send PDF file 

第155行是flash.php中的最後一行,即php(?>)的結束標記。在此之前,它是嵌入SWF的代碼。我沒有看到任何問題。

但是,它在本地服務器上顯示正常。

我檢查過空格,但錯誤仍然存​​在。

我已經在輸出之前使用ob_clean。

有人可以告訴我我做錯了什麼。僅供參考,我使用的是帶有tcpdf的cakephp。

以下是flash.php

class FlashHelper extends AppHelper {  
var $helpers = array('Javascript'); 
/** 
* Used for remembering options from init() to each renderSwf 
* 
* @var array 
*/ 
var $options = array( 
    'width' => 100, 
    'height' => 100 
); 

/** 
* Used by renderSwf to set a flash version requirement 
* 
* @var string 
*/ 
var $defaultVersionRequirement = '9.0.0'; 

/** 
* Used by renderSwf to only call init if it hasnt been done, either 
* manually or automatically by a former renderSwf() 
* 
* @var boolean 
*/ 
var $initialized = false; 

/** 
* Optional initializing for setting default parameters and also includes the 
* swf library. Should be called once, but if using several groups of flashes, 
* MAY be called several times, once before each group. 
* 
* @example echo $flash->init(); 
* @example $flash->init(array('width'=>200,'height'=>100); 
* @return mixed String if it was not able to add the script to the view, true if it was 
*/ 
function init($options = array()) { 
    if (!empty($options)) { 
     $this->options = am($this->options, $options); 
    } 
    $this->initialized = true; 
    $view =& ClassRegistry::getObject('view'); 
    if (is_object($view)) { 
     $view->addScript($this->Javascript->link('swfobject')); 
     return true; 
    } else { 
     return $this->Javascript->link('swfobject'); 
    } 
} 

/** 
* Wrapper for the SwfObject::embedSWF method in the vendor. This method will write a javascript code 
* block that calls that javascript method. If given a dom id as fourth parameter the flash will 
* replace that dom object. If false is given, a div will be placed at the point in the 
* page that this method is echo'ed. The last parameter is mainly used for sending in extra settings to 
* the embedding code, like parameters and attributes. It may also send in flashvars to the flash. 
* 
* For doucumentation on what options can be sent, look here: 
* http://code.google.com/p/swfobject/wiki/documentation 
* 
* @example echo $flash->renderSwf('counter.swf'); // size set with init(); 
* @example echo $flash->renderSwf('flash/ad.swf',100,20); 
* @example echo $flash->renderSwf('swf/banner.swf',800,200,'banner_ad',array('params'=>array('wmode'=>'opaque'))); 
* @param string $swfFile Filename (with paths relative to webroot) 
* @param int $width if null, will use width set by FlashHelper::init() 
* @param int $height if null, will use height set by FlashHelper::init() 
* @param mixed $divDomId false or string : dom id 
* @param array $options array('flashvars'=>array(),'params'=>array('wmode'=>'opaque'),'attributes'=>array()); 
*   See SwfObject documentation for valid options 
* @return string 
*/ 
function renderSwf($swfFile, $width = null, $height = null, $divDomId = false, $options = array()) { 
    $options = am ($this->options, $options);   
    if (is_null($width)) { 
     $width = $options['width']; 
    } 
    if (is_null($height)) { 
     $height = $options['height']; 
    } 
    $ret = ''; 
    if (!$this->initialized) { 
     $init = $this->init($options); 
     if (is_string($init)) { 
      $ret = $init; 
     } 
     $this->initialized = TRUE; 
    }   
    $flashvars = '{}'; 
    $params = '{wmode : "opaque"}'; 
    $attributes = '{}'; 
    if (isset($options['flashvars'])) { 
     $flashvars = $this->Javascript->object($options['flashvars']); 
    } 
    if (isset($options['params'])) { 
     $params = $this->Javascript->object($options['params']); 
    } 
    if (isset($options['attributes'])) { 
     $attributes = $this->Javascript->object($options['attributes']); 
    } 

    if ($divDomId === false) { 
     $divDomId = uniqid('c_'); 
     $ret .= '<div id="'.$divDomId.'"></div>'; 
    } 
    if (isset($options['version'])) { 
     $version = $options['version']; 
    } else { 
     $version = $this->defaultVersionRequirement;    
    } 
    if (isset($options['install'])) { 
     $install = $options['install']; 
    } else { 
     $install = '';    
    } 

    $swfLocation = $this->webroot.$swfFile; 
    $ret .= $this->Javascript->codeBlock( 
     'swfobject.embedSWF 
("'.$swfLocation.'", "'.$divDomId.'", "'.$width.'", "'.$height.'", "'.$version.'", 
      "'.$install.'", '.$flashvars.', '.$params.', '.$attributes.');'); 
     return $ret; 
    } 

} 
?> 

回答

1

只是做了錯誤告訴你:檢查應用程序/視圖/助理/ flash.php線155,看看它的輸出存在,​​並修復它。必須有一些代碼輸出一些東西。

+0

行155是flash.php的最後一行,即php(?>)的結束標記。在此之前,它是嵌入SWF的代碼。我沒有看到任何問題。 – vaanipala 2012-03-22 06:25:29

0

它可能是返回語句之一嗎?

if (is_object($view)) { 
     $view->addScript($this->Javascript->link('swfobject')); 
     return true; 
    } else { 
     return $this->Javascript->link('swfobject'); 
    } 

$ret .= $this->Javascript->codeBlock( 
     'swfobject.embedSWF 
("'.$swfLocation.'", "'.$divDomId.'", "'.$width.'", "'.$height.'", "'.$version.'", 
      "'.$install.'", '.$flashvars.', '.$params.', '.$attributes.');'); 
     return $ret; 
    } 

頁面上還有其他的代碼調用flash嗎?

相關問題