NEW add pdf function to check if pdf file is protected/encrypted

This commit is contained in:
Regis Houssin 2018-05-08 09:45:10 +02:00
parent 5fe8249706
commit 415b7425fd

View File

@ -169,6 +169,25 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
return $pdf;
}
/**
* Return if pdf file is protected/encrypted
*
* @param TCPDF $pdf PDF initialized object
* @param string $pathoffile Path of file
* @return boolean True or false
*/
function pdf_getEncryption(&$pdf, $pathoffile)
{
$isencrypted = false;
$pdfparser = $pdf->_getPdfParser($pathoffile);
$data = $pdfparser->getParsedData();
if (isset($data[0]['trailer'][1]['/Encrypt'])) {
$isencrypted = true;
}
return $isencrypted;
}
/**
* Return font name to use for PDF generation