set_option($optlist); /* @既存の PDF 文書を開く */ if (($doc = $plop->open_document($infile, "")) == 0) { die("Error: " . $plop->get_apiname() . ": " . $plop->get_errmsg() . "\n"); } /* A文書タイムスタンプを作成する */ if ($plop->prepare_signature($sign_opts) == 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=doctimestamp.pdf"); print $buf; /* CPDF文書を閉じる */ $plop->close_document($doc, ""); } catch (PLOPException $e) { die("PLOP exception occurred in doctimestamp sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $plop = 0;