public addHeader ( string $type = PHPRtfLite_Container_Header::TYPE_ALL, PHPRtfLite_Container_Header $header = null ) : PHPRtfLite_Container_Header | ||
$type | string | Represented by class constants PHPRtfLite_Container_Header::TYPE_* Possible values: PHPRtfLite_Container_Header::TYPE_ALL all pages (different odd and even headers/footers must be not set) PHPRtfLite_Container_Header::TYPE_LEFT left pages (different odd and even headers/footers must be set) PHPRtfLite_Container_Header::TYPE_RIGHT right pages (different odd and even headers/footers must be set PHPRtfLite_Container_Header::TYPE_FIRST first page |
$header | PHPRtfLite_Container_Header | |
return | PHPRtfLite_Container_Header |
public function addHeader($type = PHPRtfLite_Container_Header::TYPE_ALL, PHPRtfLite_Container_Header $header = null)
{
if ($header === null) {
$header = new PHPRtfLite_Container_Header($this, $type);
}
$this->_headers[$type] = $header;
return $header;
}
<?php $dir = dirname(__FILE__); require_once $dir . '/../lib/PHPRtfLite.php'; // register PHPRtfLite class loader PHPRtfLite::registerAutoloader(); // rtf document $rtf = new PHPRtfLite(); //paragraph formats $parFormat = new PHPRtfLite_ParFormat(); $parGreyLeft = new PHPRtfLite_ParFormat(); $parGreyLeft->setShading(10); $parGreyCenter = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER); $parGreyCenter->setShading(10); // header $header = $rtf->addHeader('first'); $header->addImage($dir . '/sources/rtf_thumb.jpg', $parFormat); $header->writeText('Image in header.', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $sect = $rtf->addSection(); $sect->writeText('Images with PHPRtfLite.', new PHPRtfLite_Font(14), new PHPRtfLite_ParFormat('center')); $sect->writeText('<br>Here is .jpg image. <tab>', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $sect->addImage($dir . '/sources/rtf_thumb.jpg', null); $sect->writeText('<br>Here is .png image. <tab>', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $sect->addImage($dir . '/sources/html.png', null); $sect->writeText('<br><br><b>Formating sizes of images:</b>', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $table = $sect->addTable(); $table->addRows(3, 4.5); $table->addRow(6); $table->addColumnsList(array(7.5, 6.5)); $table->writeToCell(1, 1, '<br> Original size.', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); //getting cell object, writing text and adding image