<?php
# ******************************
# FPDF を使用しています
# ******************************
require("http://homepage2.nifty.com/lightbox/phppdf/japanese.php");
$GLOBALS['margin'] = 5;
# ポートレイト、単位(ミリメートル)、サイズA4
$pdf = new PDF_Japanese( 'P', 'mm', 'A4' );
# 使えそうなマシンにインストール済みのフォント名
# ( GIMP で調べました )
$pdf->AddSJISFont("HGSoeiKakupoptai");
# 2ページぶんの処理
for( $page = 0; $page < 2; $page++ ) {
# ページ追加
$pdf->AddPage();
# 塗りつぶす為の色
$pdf->SetFillColor( 200, 230, 185 );
# タイトル印字
$pdf->SetFont('SJIS','B',20);
$text = 'PHP 印字テスト';
$pdf->Text( $GLOBALS['margin'], 13.5, $text );
# 通常印字フォント
$pdf->SetFont('SJIS','',10);
for( $i = 1; $i <= 20; $i++ ) {
$pdf->SetX( $GLOBALS['margin'] );
$pdf->SetY( ( $i-1 ) * 8 + 40 );
$pdf->SetTextColor( 0, 0, 0 );
# 幅、高さ、印刷文字列、罫線あり、不要、センタリング、色を塗る
$pdf->Cell( 100, 6, "$i 行", 1, 0, 'C', 1 );
}
}
# 書き込み
$pdf->Output("print.pdf");
# ******************************
# Windows 経由の 外部実行
# ******************************
$WshShell = new COM("WScript.Shell");
$command = "RunDLL32.EXE shell32.dll,ShellExec_RunDLL ";
$command .= ""print.pdf"";
$WshShell->Run( $command, 1, TRUE );
print "処理が終了しました\n";
?>