addHeader() public method

creates header for the document
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
Exemplo n.º 1
0
<?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
Exemplo n.º 2
0
<?php

$dir = dirname(__FILE__);
require_once $dir . '/../lib/PHPRtfLite.php';
// register PHPRtfLite class loader
PHPRtfLite::registerAutoloader();
//rtf document
$rtf = new PHPRtfLite();
$rtf->setHyphenation();
$header = $rtf->addHeader();
$header->writeText("PHPRtfLite class library. This is page - <pagenum> of <pagetotal> -", new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$table = $header->addTable();
$table->addRows(1);
$table->addColumnsList(array(3, 4, 3));
$cell = $table->getCell(1, 1);
$cell->setTextAlignment(PHPRtfLite_Table_Cell::TEXT_ALIGN_LEFT);
$cell->writeText('Cell with left alignment');
$cell = $table->getCell(1, 2);
$cell->setTextAlignment(PHPRtfLite_Table_Cell::TEXT_ALIGN_CENTER);
$cell->writeText('Cell with center alignment');
$cell = $table->getCell(1, 3);
$cell->setTextAlignment(PHPRtfLite_Table_Cell::TEXT_ALIGN_RIGHT);
$cell->writeText('Cell with right alignment');
$header->writeText('Text after table');
$section = $rtf->addSection();
$section->writeText('
Text with hyphenation activated:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eleifend sem dapibus erat congue quis pharetra neque porta. Cras orci quam, consectetur id vestibulum non, iaculis sit amet neque. Maecenas in tincidunt urna. Curabitur quis justo ac augue volutpat laoreet. Pellentesque molestie vestibulum diam, eu facilisis est tincidunt et. Phasellus scelerisque elit et enim luctus mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur semper, felis vehicula pharetra laoreet, erat augue porttitor nisl, quis ullamcorper purus felis vel augue. Etiam quis massa ultrices nisi rutrum auctor. Integer mollis sapien quis mauris suscipit nec dictum felis interdum.

Sed ut arcu metus. Cras lorem dolor, pharetra ut congue vel, pellentesque ac arcu. Praesent non lectus nulla. Nam mollis velit a dui lobortis tincidunt. Duis sed ipsum elit. Pellentesque urna risus, commodo in fringilla sit amet, euismod sit amet lectus. Nulla purus elit, porttitor ac viverra nec, consectetur at arcu. Pellentesque eget magna eget justo euismod mattis ut nec odio. Proin gravida est eu augue ullamcorper eu mollis orci convallis. Curabitur adipiscing lacus vitae ante accumsan ut ornare elit ultricies. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.');
Exemplo n.º 3
0
 /**
  * tests addHeader with expected exception for all page header
  * @expectedException PHPRtfLite_Exception
  */
 public function testAddHeaderAllException()
 {
     $this->_rtf->setOddEvenDifferent();
     $this->_rtf->addHeader(PHPRtfLite_Container_Header::TYPE_ALL);
     $this->_rtf->getContent();
 }
Exemplo n.º 4
0
';
$times12 = new PHPRtfLite_Font(13, 'Times new Roman');
$arial14 = new PHPRtfLite_Font(14, 'Arial', '#000066');
$parFormat = new PHPRtfLite_ParFormat();
//rtf document
$rtf = new PHPRtfLite();
//borders
$borderFormatBlue = new PHPRtfLite_Border_Format(1, '#0000ff');
$borderFormatRed = new PHPRtfLite_Border_Format(2, '#ff0000');
$border = new PHPRtfLite_Border($rtf, $borderFormatBlue, $borderFormatRed, $borderFormatBlue, $borderFormatRed);
$rtf->setBorder($border);
$rtf->setBorderSurroundsHeader();
$rtf->setBorderSurroundsFooter();
//headers
$rtf->setOddEvenDifferent();
$header = $rtf->addHeader(PHPRtfLite_Container_Header::TYPE_LEFT);
$header->writeText("PHPRtfLite class library. Left document header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat);
$header = $rtf->addHeader(PHPRtfLite_Container_Header::TYPE_RIGHT);
$header->writeText("PHPRtfLite class library. Right document header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat);
//section 1
$sect = $rtf->addSection();
$sect->setPaperHeight(16);
$sect->setPaperWidth(25);
//Borders overridden: No Borders
$border = PHPRtfLite_Border::create($rtf, 0);
$sect->setBorder($border);
$sect->setSpaceBetweenColumns(1);
$sect->setNumberOfColumns(2);
$sect->setLineBetweenColumns();
writeSectionText($sect, $arial14, $times12, $text, $text2, $text3);
//section 2