PHP code example of sotatek-ngoc-bach / thinreports-php

1. Go to this page and download the library: Download sotatek-ngoc-bach/thinreports-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sotatek-ngoc-bach / thinreports-php example snippets



// date_default_timezone_set('Asia/Tokyo');

$report = new Thinreports\Report('hello_world.tlf');

// 1st page
$page = $report->addPage();
$page->item('world')->setValue('World');
$page->item('thinreports')->setValue('Thinreports');

// 2nd page
$page = $report->addPage();
$page('world')->setValue('PHP');
$page('thinreports')->setValue('Thinreports PHP');

// 3rd page
$page = $report->addPage();
$page('world')->setValue('World')
              ->setStyle('color', '#ff0000');
$page('hello')->hide();

// 4th page
$page = $report->addPage();
$page->setItemValue('thinreports', 'PDF');
$page->setItemValues(array(
  'world' => 'PHP'
));

// 5th page
$page = $report->addPage();
$page->item('world_image')->setSource('/path/to/world.png');

// 6th page: Using other .tlf file
$page = $report->addPage('hello_php.tlf')
$page->item('world')->setValue('php');

// 7th page: Insert a blank page
$report->addBlankPage();

$report->generate('hello_world.pdf');

// You can get content of the PDF in the following code:
$pdf_data = $report->generate();