set_option($optlist); /* 基本的な署名オプション */ $optlist = $sign_opts; /* @既存の PDF 文書を開く */ if (($doc = $plop->open_document($infile, "")) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* A電子署名を作成する */ if ($plop->prepare_signature($optlist) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* B電子署名を PDF に付与して出力する */ if ($plop->create_document($outfile, "input=". $doc) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* PDF 文書のデータを変数に格納する */ $buf = $plop->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=sign.pdf"); print $buf; /* CPDF文書を閉じる */ $plop->close_document($doc, ""); } catch (PLOPException $e) { die("PLOP exception occurred in sign sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $plop = 0;