自定义Joomla PDF输出

问题描述:

在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等)?

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