ksimon
ksimon

Reputation: 711

Customizing Joomla PDF output

In Joomla 1.5 constructor of JDocumentPDF class has an array parameter to setup some parameter of generated PDF.

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() function of JFactory class instantiates JDocumentPDF object, but doesn't pass any options that useful for PDF generation:

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;
}

So I don't understand how it works and where can I set this options (margin-header, margin-footer etc)?

Upvotes: 1

Views: 1252

Answers (1)

Gaurav
Gaurav

Reputation: 28755

To set and get any properties of JDocumentPDF

you can call set and get function on object. For example

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

Upvotes: 4

Related Questions