function setup()
 {
     $report = new Report($this->dataLayoutFile('empty.tlf'));
     $parent = $report->addPage();
     $format = ['type' => 'test-block', 'display' => 'true', 'box' => ['x' => 100, 'y' => 100, 'width' => 100, 'height' => 100]];
     $this->test_item = new TestBlockItem($parent, $format);
 }
 /**
  * @return string
  */
 public function render()
 {
     foreach ($this->report->getPages() as $page) {
         if ($page->isBlank()) {
             $this->doc->addBlankPage();
         } else {
             $this->renderPage($page);
         }
     }
     return $this->doc->render();
 }
Example #3
0
 function test_createItem()
 {
     $item_formats = $this->dataItemFormats(array(array('text_block', 'default'), array('image_block', 'default'), array('page_number', 'default'), array('rect', 'default'), array('ellipse', 'default'), array('line', 'default'), array('image', 'default'), array('text', 'default')));
     $layout = new Layout(array('svg' => '<svg></svg>'), $item_formats);
     $dummy_report = new Report($this->dataLayoutFile('empty.tlf'));
     $dummy_page = $dummy_report->addPage();
     $this->assertInstanceOf('Thinreports\\Item\\TextBlockItem', $layout->createItem($dummy_page, 'text_block_default'));
     $this->assertInstanceOf('Thinreports\\Item\\ImageBlockItem', $layout->createItem($dummy_page, 'image_block_default'));
     $this->assertInstanceOf('Thinreports\\Item\\PageNumberItem', $layout->createItem($dummy_page, '__page_no_1__'));
     $graphic_ids = array('rect_default', 'ellipse_default', 'line_default', 'image_default', 'text_default');
     foreach ($graphic_ids as $id) {
         $this->assertInstanceOf('Thinreports\\Item\\BasicItem', $layout->createItem($dummy_page, $id));
     }
     try {
         $layout->createItem($dummy_page, 'unknown_id');
         $this->fail();
     } catch (Exception\StandardException $e) {
         $this->assertEquals('Item Not Found', $e->getSubject());
     }
 }
 function setup()
 {
     $report = new Report($this->dataLayoutFile('empty.tlf'));
     $this->page = $report->addPage();
 }
 /**
  * @param Report $report
  */
 public function __construct(Report $report)
 {
     $this->report = $report;
     $this->pdf = new PDF\Document($report->getDefaultLayout());
 }
<?php

require __DIR__ . '/../../vendor/autoload.php';
date_default_timezone_set('Asia/Tokyo');
use Thinreports\Report;
$report = new Report(__DIR__ . '/hello_world.tlf');
$page = $report->addPage();
$page->item('world')->setValue('World');
$page->item('sekai')->setValue('世界');
$page = $report->addPage();
$page('world')->setValue('World');
$page('sekai')->setValue('世界');
$page = $report->addPage();
$page->setItemValue('world', 'World');
$page->setItemValue('sekai', '世界');
$report->addPage(function ($new_page) {
    $new_page('world')->setValue('World')->setStyle('color', 'blue');
    $new_page('sekai')->setValue('世界');
});
$page = $report->addPage();
$page->setItemValues(['world' => 'World', 'sekai' => '世界']);
$report->addPage()->setItemValues(['world' => 'World', 'sekai' => '世界']);
$report->generate(__DIR__ . '/hello_world.pdf');
<?php

require __DIR__ . '/../../vendor/autoload.php';
date_default_timezone_set('Asia/Tokyo');
use Thinreports\Report;
$report = new Report(__DIR__ . '/hello_world.tlf');
$page = $report->addPage();
$page->item('world')->setValue('World');
$page->item('sekai')->setValue('世界');
$page = $report->addPage();
$page('world')->setValue('World');
$page('sekai')->setValue('世界');
$page = $report->addPage();
$page->setItemValue('world', 'World');
$page->setItemValue('sekai', '世界');
$page = $report->addPage();
$page->setItemValues(array('world' => 'World', 'sekai' => '世界'));
$report->addPage()->setItemValues(array('world' => 'World', 'sekai' => '世界'));
$report->generate(__DIR__ . '/hello_world.pdf');