<?php

$templatePDF 
'560-0201.pdf';

$p PDF_new();

// Acrobat 5 でも読めるようにする場合、1.4 を指定します。
PDF_begin_document($p'''compatibility=1.5');

// 暗号化された PDF ファイルを読み込むときは下記のように password に
// パスワードを指定します(PDF にマスタパスワードが設定されている場合には
// マスタパスワードのパスワードを指定します)。
// $doc = PDF_open_pdi($p, $templatePDF, "password=hoge pdiwarning=true", 0);
$doc PDF_open_pdi($p$templatePDF"pdiwarning=true"0);

$page PDF_open_pdi_page($p$doc1"");

// ページは A4 サイズ
PDF_begin_page_ext($p595842'');

// 読み込んだページを出力
PDF_fit_pdi_page($p$page00"adjustpage");

// テキストの出力
PDF_setcolor($p"fill""rgb"1000);
$font PDF_load_font($p"KozGoPro-Medium-Acro""EUC-H""");
PDF_setfont($p$font15);
PDF_show_xy($p"PDIサンプル友の会"120645);

PDF_setfont($p$font10);
PDF_show_xy($pdate("Y"), 358692);
PDF_show_xy($pdate("m"), 427692);
PDF_show_xy($pdate("d"), 475692);

PDF_end_page_ext($p'');

PDF_close_pdi_page($p$page);
    
PDF_close_pdi($p$doc);

PDF_end_document($p'');

$buf PDF_get_buffer($p);
header("Content-Type: application/pdf");
header("Content-Length: " strlen($buf));
header("Content-Disposition: inline; filename=sample_pdi.pdf");
print 
$buf;

PDF_delete($p);

?>