From b7c966ef825fbdd1085dac115c0960cb6fcab35f Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Wed, 22 Dec 2010 12:08:47 +0000
Subject: [PATCH] Fix: PDF permissions

---
 htdocs/lib/pdf.lib.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php
index b81a855b2d3..2b5c31e2e7c 100644
--- a/htdocs/lib/pdf.lib.php
+++ b/htdocs/lib/pdf.lib.php
@@ -54,10 +54,18 @@ function pdf_getInstance($format,$metric='mm',$pagetype='P')
         - print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
         - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
         */
-        if ($conf->global->MAIN_USE_FPDF) $pdf = new FPDI_Protection($pagetype,$metric,$format);
-        else $pdf = new FPDI($pagetype,$metric,$format);
-        $pdfrights = array('print'); // Ne permet que l'impression du document
-        if (empty($conf->global->MAIN_USE_FPDF)) $pdfrights[]='assemble';
+        if ($conf->global->MAIN_USE_FPDF)
+        {
+            $pdf = new FPDI_Protection($pagetype,$metric,$format);
+            // For FPDF, we specify permission we want to open
+            $pdfrights = array('print');
+        }
+        else
+        {
+            $pdf = new FPDI($pagetype,$metric,$format);
+            // For TCPDF, we specify permission we want to block
+            $pdfrights = array('modify','copy');
+        }
         $pdfuserpass = ''; // Mot de passe pour l'utilisateur final
         $pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini
         $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
-- 
GitLab