"../data/demo_recipient_1.pem", "perm"=>"" ), /* フォームの入力及び署名のアクセス権限を付与し、 他の権限は制限する */ array( "cert"=>"../data/demo_recipient_2.pem", "perm"=>"nomodify nocopy noannots noassemble" ), array( "cert"=>"../data/demo_recipient_3.pem", "perm"=>"nomodify nocopy noannots noassemble" ), ); /* 本サンプルに必要なデータが保存されているディレクトリを指定する */ $searchpath = "../data ../../data"; try { /* PLOP オブジェクトを生成する */ $plop = new PLOP(); $infile = "PLOP-datasheet.pdf"; $outfile = ""; $optlist; /* 読み込みたいファイルの入ったディレクトリを指定する */ $optlist = sprintf("searchpath={%s}", $searchpath); $plop->set_option($optlist); /* @既存の PDF 文書を開く */ if (($doc = $plop->open_document($infile, "")) == 0) { die("Error: " . $plop->get_errmsg() . "\n"); } /* A受信者証明書を指定する */ for ($r = 0; $r < count($recipients); $r++) { $optlist = sprintf("certificate={filename={%s}} permissions={%s}", $recipients[$r]{"cert"}, $recipients[$r]{"perm"}); if ($plop->add_recipient($optlist) == -1) { /* 警告を出して、処理を続行します */ printf("Error: " . $plop->get_errmsg() . "\n"); } } /* B暗号化をした PDF を出力する */ $optlist = sprintf("input=%d", $doc); if ($plop->create_document($outfile, $optlist) == 0) { die("Error: " . $plop->get_errmsg() . "\n"); } $buf = $plop->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=certsec.pdf"); print $buf; /* CPDF文書を閉じる */ $plop->close_document($doc, ""); } catch (PLOPException $e) { die("PLOP exception occurred in certsec sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $plop = 0;