2011-02-13 103 views
1

在Joomla 1.5的構造函數JDocumentPDF類有一個數組參數來設置生成的PDF的一些參數。自定義Joomla PDF輸出

功能 JFactory
function __construct($options = array()) { 
    parent::__construct($options); 

    if (isset($options['margin-header'])) { 
     $this->_margin_header = $options['margin-header']; 
    } 

    if (isset($options['margin-footer'])) { 
     $this->_margin_footer = $options['margin-footer']; 
    } 

    if (isset($options['margin-top'])) { 
     $this->_margin_top = $options['margin-top']; 
    } 
    ... 
} 

_createDocument()類實例化JDocumentPDF對象,但沒有通過任何選項,對PDF生成有用:

function &_createDocument()  { 

    ... 

    $attributes = array (
     'charset' => 'utf-8', 
     'lineend' => 'unix', 
     'tab'  => ' ', 
     'language' => $lang->getTag(), 
     'direction' => $lang->isRTL() ? 'rtl' : 'ltr' 
    ); 

    $doc =& JDocument::getInstance($type, $attributes); 
    return $doc; 
} 

所以我不明白它是如何工作的,我在那裏可以設置這個選項(margin-header,margin-footer等)?

回答

4

setgetJDocumentPDF

任何屬性你可以調用設置和object獲取功能。例如

$obj = JFactory::getDocument(); 
$marginHeader = $obj->get('_margin_header'); 
$obj->set('_margin_header', $value); 
+0

get和set將與Joomla繼承的joomla類的ll對象一起工作。 – Gaurav 2011-02-13 17:15:24