From 25a87507b9548646cebac902b7fdc24396102e35 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 14 Apr 2018 15:12:51 +0200 Subject: [PATCH] NEW add new parameters for tcpf encryption --- htdocs/core/lib/pdf.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 41e53059fff..9de6dcd5c1c 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -150,11 +150,18 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') */ // For TCPDF, we specify permission we want to block - $pdfrights = array('modify','copy'); + $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?$conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS:array('modify','copy')); + + // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit + $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); + + // Array of recipients containing public-key certificates ('c') and permissions ('p'). + // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) + $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?$conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS:null); $pdfuserpass = ''; // Password for the end user $pdfownerpass = NULL; // Password of the owner, created randomly if not defined - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass,$encstrength,$pubkeys); } return $pdf;