예제 #1
0
 /**
  * tests create
  */
 public function testCreateBorder()
 {
     $rtf = new PHPRtfLite();
     $border = PHPRtfLite_Border::create($rtf, 1.5, '#ff0', PHPRtfLite_Border_Format::TYPE_SINGLE, 5);
     $this->assertType('PHPRtfLite_Border_Format', $border->getBorderTop());
     $this->assertType('PHPRtfLite_Border_Format', $border->getBorderBottom());
     $this->assertType('PHPRtfLite_Border_Format', $border->getBorderRight());
     $this->assertType('PHPRtfLite_Border_Format', $border->getBorderLeft());
 }
예제 #2
0
$table->writeToCell(3, 2, '<br>   ', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$table->addImageToCell(3, 2, $dir . '/sources/cats.jpg', null, 0, 3.5);
$table->writeToCell(4, 1, '<br> Both: width and height are set.', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$cell = $table->getCell(4, 2);
$cell->writeText('<br>   ', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$img = $cell->addImage($dir . '/sources/cats.jpg', null, 3, 5);
$sect->writeText('<page/><b>Borders of images</b>', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$table = $sect->addTable();
$table->addRows(2, 4.5);
$table->addRows(2, 6);
$table->addColumnsList(array(7.5, 6.5));
$table->writeToCell(1, 1, '<br> Sample borders', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$cell = $table->getCell(1, 2);
$cell->writeText('<br>   ', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$img = $cell->addImage($dir . '/sources/cats.jpg', null);
$border = PHPRtfLite_Border::create($rtf, 3, '#000000');
$img->setBorder($border);
$table->writeToCell(2, 1, '<br> Borders with space', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$cell = $table->getCell(2, 2);
$img = $cell->addImage($dir . '/sources/cats.jpg', null);
$borderFormatBlue = new PHPRtfLite_Border_Format(2, '#0000ff', 'simple', 0.5);
$borderFormatRed = new PHPRtfLite_Border_Format(2, '#ff0000', 'simple', 0.5);
$border = new PHPRtfLite_Border($rtf);
$border->setBorderLeft($borderFormatRed);
$border->setBorderTop($borderFormatBlue);
$border->setBorderRight($borderFormatRed);
$border->setBorderBottom($borderFormatBlue);
$img->setBorder($border);
$table->writeToCell(3, 1, '<br> Image centered by ParFormat', new PHPRtfLite_Font());
$cell = $table->getCell(3, 2);
$parFormatCenter = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER);
예제 #3
0
 /**
  * Save the current file
  * @param $filename file name
  */
 public function save($filename)
 {
     // instancia um objeto para estilo de borda
     $border = PHPRtfLite_Border::create(0.7, '#000000');
     // liga as bordas na tabela
     $this->table->setBorderForCellRange($border, 1, 1, $this->table->getRowsCount(), $this->table->getColumnsCount());
     // armazena o documento em um arquivo
     $this->rtf->save($filename);
     return TRUE;
 }
예제 #4
0
$smallWidth = '0.75';
$bigWidth = ($sect->getLayoutWidth() - $countSmall * $smallWidth) / $countLarge;
$table = $sect->addTable();
$table->addRows(16, -0.5);
$table->addColumnsList(array($smallWidth, $bigWidth, $bigWidth, $smallWidth, $smallWidth, $bigWidth, $bigWidth, $smallWidth, $smallWidth, $bigWidth, $bigWidth));
$table->setTextAlignmentForCellRange('center', 1, 1, 16, 11);
$table->setFontForCellRange(new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'), 1, 1, 16, 11);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 2, 1, 3, 3);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 6, 1, 7, 3);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 10, 1, 11, 3);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 14, 1, 15, 3);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 4, 5, 5, 7);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 12, 5, 13, 7);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 8, 9, 9, 11);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 14, 9, 15, 11);
$table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 1, 10, 3, 11);
$table->writeToCell(2, 1, 'P1', $font1, null);
$table->writeToCell(3, 1, 'P8', $font1, null);
$table->writeToCell(6, 1, 'P2', $font1, null);
$table->writeToCell(7, 1, 'P7', $font1, null);
$table->writeToCell(10, 1, 'P3', $font1, null);
$table->writeToCell(11, 1, 'P6', $font1, null);
$table->writeToCell(14, 1, 'P4', $font1, null);
$table->writeToCell(15, 1, 'P5', $font1, null);
$table->writeToCell(1, 1, 'A1', $font1, null);
$table->writeToCell(5, 1, 'A2', $font1, null);
$table->writeToCell(9, 1, 'A3', $font1, null);
$table->writeToCell(13, 1, 'A4', $font1, null);
$table->writeToCell(3, 5, 'B1', $font1, null);
$table->writeToCell(4, 5, 'A1', $font1, null);
$table->writeToCell(5, 5, 'A2', $font1, null);
예제 #5
0
<?php

$dir = dirname(__FILE__);
require_once $dir . '/../lib/PHPRtfLite.php';
PHPRtfLite::registerAutoloader();
$rtf = new PHPRtfLite();
$sect = $rtf->addSection();
$table = $sect->addTable();
$table->addRows(5, 0.75);
$table->addColumnsList(array(3, 3, 3, 3, 3));
$table->mergeCellRange(1, 1, 3, 1);
$table->writeToCell(1, 1, 'Vertical merged cells.', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$border = PHPRtfLite_Border::create($rtf, 1, '#ff0000');
$table->setBorderForCellRange($border, 1, 1, 3, 1);
$table->mergeCellRange(1, 3, 1, 5);
$table->writeToCell(1, 3, 'Horizontal merged cells', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$border = PHPRtfLite_Border::create($rtf, 1, '#0000ff');
$table->setBorderForCellRange($border, 1, 3, 1, 5);
$table->mergeCellRange(3, 3, 5, 5);
$table->writeToCell(3, 3, 'Horizontal and vertical merged cells', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$border = PHPRtfLite_Border::create($rtf, 1, '#00ff00');
$table->setBorderForCellRange($border, 3, 3, 5, 5);
// save rtf document
$rtf->save($dir . '/generated/' . basename(__FILE__, '.php') . '.rtf');
예제 #6
0
$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
$sect = $rtf->addSection();
$sect->setBorderSurroundsHeader();
$sect->setBorderSurroundsFooter();
//Header overridden
$header = $sect->addHeader(PHPRtfLite_Container_Header::TYPE_RIGHT);
$header->writeText("PHPRtfLite class library. Overriden right section header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat);
$header = $sect->addHeader(PHPRtfLite_Container_Header::TYPE_LEFT);
$header->writeText("PHPRtfLite class library. Overriden left section header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat);
//Borders overridden: Green border
$border = PHPRtfLite_Border::create($rtf, 1, '#00ff00', PHPRtfLite_Border_Format::TYPE_DASH, 1);
$sect->setBorder($border);
writeSectionText($sect, $arial14, $times12, $text, $text2, $text3);
//
//section 3
$sect = $rtf->addSection();
$sect->setColumnWidths(array(3, 3, 8));
//Border from rtf
//....
writeSectionText($sect, $arial14, $times12, $text, $text2, $text3);
// save rtf document
$rtf->save($dir . '/generated/' . basename(__FILE__, '.php') . '.rtf');