Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.144.3.235
<?php
function pdfEncrypt($origFile, $password, $destFile)
{
require_once('fpdi/FPDI_Protection.php');
$pdf =& new FPDI_Protection();
$pdf->FPDF();
$pagecount = $pdf->setSourceFile($origFile);
// copy all pages from the old unprotected pdf in the new one
for ($loop = 1; $loop <= $pagecount; $loop++)
{
$tplidx = $pdf->importPage($loop);
$pdf->addPage();
$pdf->useTemplate($tplidx);
}
// protect the new pdf file, and allow no printing, copy etc and leave only reading allowed
$pdf->SetProtection(array(), $password, '');
$pdf->Output($destFile);
return $destFile;
}
/* $password = "info@domain.com";
$origFile = "book.pdf";
$destFile ="book_protected.pdf";
pdfEncrypt($origFile, $password, $destFile ); */
?>
|