【发布时间】:2020-06-16 08:39:42
【问题描述】:
有没有办法使用 MPDF 库 (PHP) 解密 pdf?
我收到了来自第 3 方的 pdf,他们正在使用 FPDI 对其进行加密。我正在使用MPDF 使其受密码保护。在访问加密的 pdf 时,如果没有加密,很容易制作受密码保护的 pdf 我收到此异常:
This PDF document is encrypted and cannot be processed with FPDI
我相信这是不可能的,一旦我有解密 pdf 的密钥就可以做到这一点,仍然想再次确认是否有办法绕过这个?
适用于非加密 pdf。
try{
$mpdf = new \Mpdf\Mpdf();
$filename = "pdfs/signed.pdf";
password="Test";
$pagecount = $mpdf->SetSourceFile($filename); //use any pdf you want
for ($i= 1; $i<=$pagecount; $i++ ){
$tplId = $mpdf->importPage($i);
$mpdf->UseTemplate($tplId);
$mpdf->AddPage();
}
echo "setting protection </br>";
$mpdf->SetProtection(array(), $password, $password);
echo "saving file: </br>";
$mpdf->Output($filename, \Mpdf\Output\Destination::FILE);
echo "done";
} catch (Exception $ex) {
echo "exception : ";
echo $ex->getMessage();
}
【问题讨论】:
标签: pdf encryption mpdf fpdi