如何在PHP中检查PDF文件是否受密码保护[关闭]

How can I check if uploading a PDF file is password protected or not while uploading multiple files using PHP? I want to show an error if it's password protected.

i found a similiar post on the web check it out.

http://drupal.org/node/843516

/**
* Check whether pdf is encrypted or password protected.
* @param <type> $form
* @param <type> $form_state
*/
function pdftest_is_encrypted($form,&$form_state) {    
     include_once 'sites/all/libraries/fpdi/pdf_parser.php';    
     foreach($form_state['values']['files'] as $value) {
       //Check whether file type is pdf and confirm the file is selected to remove.
        if($value['filemime'] == 'application/pdf' && $value['remove'] != 1) {
          $pdf = new pdf_parser($value['filepath']);                   
          if(stristr($pdf->errormsg,'File is encrypted')) {
              form_set_error('field_attachment', t('Uploaded PDF Document '.$value['filename'].' is encrypted and can not be uploaded. '.l('Guide to troubleshooting failed uploads.','http://support.scribd.com/forums/33627/entries/24412')));
          }
        }
     }

This question is a variation of is it possible to check if pdf is password protected using ghostscript? (you might just need to execute the shell script provided there, which relies on ghostcript )