Last active
November 23, 2015 12:17
-
-
Save hidakatsuya/36d2411619529cc66683 to your computer and use it in GitHub Desktop.
Pure-PHP で帳票とか PDF を作成する ref: http://qiita.com/hidakatsuya/items/05eaae740f1523a87685
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"thinreports-php/thinreports-php": "@alpha" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd ~/Desktop/hello_world | |
$ composer install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php hello_world.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// なんでも | |
$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 | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$report->generate(); // => PDF data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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