mercredi 19 août 2020

Larvel set Pdf Protection

I want to make a function in laravel 5.5 to set a password on a PDf file. I tried it by using library

use setasign\FpdiProtection\FpdiProtection;
$pdf = new FpdiProtection();
          $pagecount = $pdf->setSourceFile($request->file('file'));
    for ($i = 1; $i <= $pagecount; $i++) {
        $tplidx = $pdf->importPage($i);
      
        $specs = $pdf->getTemplateSize($tplidx);
      
        $pdf->addPage($specs['orientation'], [ $specs['width'], $specs['height'] ]);
        $pdf->useTemplate($tplidx);
    }
    $pdf->setProtection(
        FpdiProtection::PERM_PRINT | FpdiProtection::PERM_COPY,
        'the user password',
        'the owner password'
    );

    $pdf->save($FilePathPdf);

But it is not working. it give following error

message: Type error: Argument 1 passed to setasign\Fpdi\Fpdi::getPdfParserInstance() must be an instance of setasign\Fpdi\PdfParser\StreamReader, instance of Illuminate\Http\UploadedFile given, called in /home/mumar/Projects/ilovepdf/vendor/setasign/fpdi/src/FpdiTrait.php on line 178



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire