begin_document("", ""); /* 文書の作成者やタイトル等、文書情報フィールドを設定する */ $p->set_info("Creator", "hellosign.php"); $p->set_info("Author", "Rainer Plockl"); $p->set_info("Title", "Hello, world/signed (PHP)!"); /* Aフォントをロードする */ $font = $p->load_font("Helvetica-Bold", "host", ""); /* BPDF 文書ページを開く */ $p->begin_page_ext(595, 842, ""); /* C位置決めをして文字列を出力する */ $p->setfont($font, 24); $p->set_text_pos(50, 700); $p->show("Hello, world/signed!"); $p->continue_text("(says PHP)"); /* DPDF ページを閉じる EPDF 文書を閉じる */ $p->end_page_ext(""); $p->end_document(""); /* Fメモリ内にある PDF 文書データを取得 */ $contents = $p->get_buffer(); /* ----------- ステップ2 : PLOP DS を用いて文書に署名する ---------- */ /* PLOP オブジェクトを作成する */ $plop = new PLOP(); /* 読み込みたいファイルの入ったディレクトリを指定する */ $plop->set_option("searchpath={{$searchpath}}"); /* GPVF(PDFlib Virtual File System)ファイルを生成する */ $plop->create_pvf("/pvf/hello.pdf", $contents, ""); /* HPVF ファイルから PDFlib で作った文書を開く */ if (($doc = $plop->open_document("/pvf/hello.pdf", "")) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* I電子署名を作成する */ if ($plop->prepare_signature( $sign_opts) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* J電子署名を PDF に付与して出力する */ if ($plop->create_document($out_filename, "input=" . $doc) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* KPDF文書を閉じる */ $plop->close_document($doc, ""); /* LPVFファイルを削除する */ if ($plop->delete_pvf("/pvf/hello.pdf") == 0) { die("Error: %s\n" . $plop->get_errmsg()); } } catch (PLOPException $e) { die("PLOP exception occurred in hellosign sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $p = 0; header("text/html"); print "click here to open the signed PDF file"; ?>