タカピロード同盟 - www.takapilord.org -  

備忘録アーカイブ


2009年2月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
FPDF(FPDI)で作成したファイルにパスワードをつける (2009-2-18)

有償ライブラリを買わないといけないかと思っていたら、
FPDI_Protectionなるものがあるのですね…

japanese.phpで日本語化して使っている場合の設置方法をメモ。

1.ググってダウンロード
2.FPDIの設置ディレクトリにFPDI_Protection.phpファイルを置く
3.japanese.phpを編集
・require('FPDI_Protection.php');を追加
・classのextendsオプションをFPDI_Protectionに変更
・「日本語フォントが読めなくって文字化け」対応
/* $this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering ('.$font['registry']['ordering'].') /Supplement '.$font['registry']['supplement'].'>>'); */
$this->_out('/CIDSystemInfo <</Registry '.$this->_textstring('Adobe').' /Ordering
'.$this->_textstring($font['registry']['ordering']).' /Supplement '.$font['registry']['supplement'].'>>');

これで、既存のソースのまま、パスワードをつける関数呼び出しだけで使用可能。
$pdf->SetProtection(array('print'), 'hogehoge');
これで、パスワード「hogehoge」で、表示後印刷だけ可能なPDFが作成できる。

 (c)2004-2007 master@takapilord.org