11/06/2016

PHP : How to password protect pdf in PHP By TCPDF


PHP : How to password protect pdf in PHP By TCPDF

insert the code after the TCPDF object is created:

  1. $pdf->SetProtection($permissions=array('print', 'copy'), $user_pass='PASSWORD', $owner_pass=null, $mode=0, $pubkeys=null);


Example :
  1. /* create new PDF document*/
  2. $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  3. $pdf->SetProtection($permissions=array('print', 'copy'), $user_pass='123456', $owner_pass=null, $mode=0, $pubkeys=null);

Open on web browser.


Save file and open on program pdf.
 
****** Function On TCPDF *********
  1. public function SetProtection($permissions=array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'), $user_pass='', $owner_pass=null, $mode=0, $pubkeys=null)
  2. {
  3.  
  4. }

No comments:

Post a Comment