set_option($optlist); /* @既存の PDF 文書を開く */ $optlist = sprintf("password {%s} ", $in_password); if (!($doc = $plop->open_document($in_filename, $optlist))) { die("Error: " . $plop->get_errmsg()); } /* Aパスワードを付与して PDF を出力する */ $optlist = sprintf("masterpassword {%s} userpassword {%s} permissions {%s} input=%d", $out_master, $out_user, $permissions, $doc); if (!$plop->create_document($out_filename, $optlist)) { die("Error: " . $plop->get_errmsg()); } $buf = $plop->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=encrypt.pdf"); print $buf; /* BPDF 文書を閉じる */ $plop->close_document($doc, ""); } catch (PLOPException $e) { die("PLOP exception occurred in encrypt sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $plop = 0;