Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hidakatsuya
Last active November 23, 2015 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidakatsuya/36d2411619529cc66683 to your computer and use it in GitHub Desktop.
Save hidakatsuya/36d2411619529cc66683 to your computer and use it in GitHub Desktop.
Pure-PHP で帳票とか PDF を作成する ref: http://qiita.com/hidakatsuya/items/05eaae740f1523a87685
{
"require": {
"thinreports-php/thinreports-php": "@alpha"
}
}
$ cd ~/Desktop/hello_world
$ composer install
$ php hello_world.php
// なんでも
$page->item('any_object')->hide();
$page->item('any_object')->show();
$page->item('any_object')->setVisible(true);
// 四角形, 楕円形, 線形
$page->item('rect_id')->setStyle('border_width', 1)
->setStyle('border_color', '#0000ff')
->setStyle('fill_color', '#ff0000')
// テキスト, テキストブロック
$page->item('text_id')->setStyles(array(
'color' => 'blue',
'align' => 'center', // left, center, right
'valign' => 'bottom' // top, center, bottom
'font_size' => 20,
'bold' => true,
'italic' => false,
'linethrough' => true,
'underline' => false
));
$report->generate(); // => PDF data
<?php
require 'vendor/autoload.php';
date_default_timezone_set('Asia/Tokyo');
$report = new Thinreports\Report('layout.tlf');
# 1st page
$page = $report->addPage();
$page->item('hello_world')->setValue('Hello World');
# 2nd page
$page = $report->addPage();
$page('hello_world')->setValue('Hello Thinreports')
->setStyle('color', '#ff0000');
$report->generate('hello_world.pdf');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment