| <?php
require('japanese.php');
class PDF_lightbox extends PDF_japanese
{
public $bx = 0;
public $by = 0;
# **********************************************************
# 新規ページ
# **********************************************************
function newUserPage($Title,$Option="") {
# 新しいページを追加
# P : ポートレイト( 縦 )
# 背景色 セット
$this->AddPage('P');
$this->SetFillColor( 255, 255, 255 );
# 号
$this->SetFont( 'SJIS', '', 12 );
$this->LocText( 150, -20, '第 号' );
# タイトル印字
$this->SetFont( 'SJIS', 'B', 20 );
$this->LocText( 65, 0, $Title );
# 個人情報
$x = 40;
$y = 23;
WritePng();
// 氏名
$this->SetFont( 'SJIS', '', 16 );
// $this->LocText( 40, 23, "山田 太郎" );
$this->Image( session_id()."name.png", 40, 90, 0, 5 );
$x = 40;
$y = 60;
$this->SetFont( 'SJIS-2', 'B', 18 );
$Text = '上記の者は、間違い無く';
$this->LocText( $x, $y, $Text );
$this->SetFont( 'SJIS-2', 'I', 18 );
$Text = '銀プログラマである事を';
$this->LocText( $x, $y+20, $Text );
$this->SetFont( 'SJIS-2', 'B', 18 );
$Text = '証明致します。';
$this->LocText( $x, $y+40, $Text );
$dt = explode( "/", date("m/d/Y") );
// 平成
$this->SetFont( 'SJIS', 'B', 13 );
$dt[2] = ($dt[2]+0) - 1988;
$this->LocText( $x+7, $y+60, "平成" );
$this->LocText( $x+20, $y+60, sprintf( "%d年", $dt[2]+0 ), 'I', 12 );
$this->LocText( $x+37, $y+60, sprintf( "%d月", $dt[0]+0 ) );
$this->LocText( $x+50, $y+60, sprintf( "%d日", $dt[1]+0 ) );
$this->SetFont( 'SJIS', 'B', 13 );
$this->LocText( $x+40, $y+95, "架空法人 システム家成育社" );
$this->LocText( $x+40, $y+105, "SQLの窓学院" );
$this->LocText( $x+68, $y+115, "校 長" );
$this->LocText( $x+94, $y+115, "lightbox" );
}
# **********************************************************
# 印字基点座標設定
# **********************************************************
function LocText( $x, $y, $str, $style='NONE', $size=14 ) {
if ( $style != 'NONE' ) {
$this->SetFont('SJIS',$style,$size);
}
$this->Text( $this->bx + $x, $this->by + $y, $str );
}
# **********************************************************
# 印字基点座標設定
# **********************************************************
function SetBase( $x=0, $y=0 ) {
$this->bx = $x;
$this->by = $y;
}
}
# ***********************************************************
# 画像化
# ***********************************************************
function WritePng() {
$font_path = "./";
# ***********************************************************
# 画像の大きさ
# ***********************************************************
$im = imagecreate(900,50); // 大きめに設定
# ***********************************************************
# 画像の背景色
# ***********************************************************
$white = imagecolorallocate($im, 255,255,255);
# ***********************************************************
# 画像の文字色
# ***********************************************************
$black = imagecolorallocate($im, 0,0,0);
# ***********************************************************
# フォントを使用した文字の画像化 16
# ***********************************************************
imagettftext(
$im,
40, // 大きめに設定
0,
10,
45,
$black,
"{$font_path}sazanami-mincho.ttf",
mb_convert_encoding( $_GET['text'], "UTF-8", "SHIFT_JIS" ));
# ***********************************************************
# PNG 出力
# ***********************************************************
imagepng($im,session_id()."name.png",9);
# ***********************************************************
# 終了処理
# ***********************************************************
imagecolordeallocate( $im, $black );
imagecolordeallocate( $im, $white );
imagedestroy($im);
}
# ***********************************************************
# 使用済み画像の削除
# ***********************************************************
function RemovePdf() {
$DirHandle = @opendir("./");
if ( $DirHandle ) {
$Target = readdir( $DirHandle );
while( $Target !== false ) {
if ( $Target != "." ) {
$ext = strrchr( $Target, "." );
$ext = strtolower($ext);
if ( $ext == ".png" ) {
$astamp = stat($Target);
$laststamp = $astamp[9];
if ( $laststamp < time() - 300 ) {
@unlink($Target);
}
}
}
$Target = readdir( $DirHandle );
}
closedir( $DirHandle );
}
}
?>
| |