使用MPDF解密加密的pdf

使用MPDF解密加密的pdf,pdf,encryption,mpdf,fpdi,Pdf,Encryption,Mpdf,Fpdi,有没有办法用MPDF库PHP解密pdf 我收到一份来自第三方的pdf文件,他们正在使用FPDI对其进行加密。我使用MPDF使其具有密码保护。在访问加密pdf时,如果未加密,则很容易制作受密码保护的pdf。我遇到以下异常: This PDF document is encrypted and cannot be processed with FPDI 我相信这是不可能的,这是可以做到的,一旦我有密钥解密的pdf文件,仍然想再次确认,如果有无论如何要通过这 适用于非加密PDF try

有没有办法用MPDF库PHP解密pdf

我收到一份来自第三方的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();
     } 

如果您知道所有者密码,在将其传递给FPDI之前,您可以使用非免费组件对其进行解密:

$writer = new SetaPDF_Core_Writer_File('result.pdf');
$document = SetaPDF_Core_Document::loadByFilename('encrypted.pdf', $writer);

// get an instance of the security handler
$secHandler = $document->getSecHandler();
if ($secHandler) {
    // try to authenticate as the owner
    if (!$secHandler->authByOwnerPassword('OWNER PASSWORD')) {
        throw new Exception('Unable to authenticate as "owner".');
    }

    // remove security handler
    $document->setSecHandler(null);
}

$document->save()->finish();