Categories: php, laravel, fpdf, mpdf

mpdf file laravel 5.8 , An error occurs when playing some pdf files while others are working fine Carry it out using the framework laravel

1 answer

An error occurs when playing some pdf files while others are working fine Carry it out using the framework laravel error:

setasign \ Fpdi \ PdfParser \ CrossReference \ CrossReferenceException (267) This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)

use Mpdf\Mpdf;  use App\Sort_table; use Illuminate\Support\Facades\Storage; use \Illuminate\Filesystem\Filesystem ;  class PDFController extends Controller{ public  function showFilepdf($file){        $path= storage_path("app\public\upload\\".$file->textPDF);    //$numberpage=$request->input("numberpage");   $numberpage=1;         // $pdfid =pdf::find($id);          // create a log channel         $logger = new Logger('name');         $logger->pushHandler(new StreamHandler('your.log', Logger::DEBUG));          $pdf = new Mpdf(['tempDir' => __DIR__ . '/mytemp'] ,['mode' => 'utf-8', 'format' => 'A4-L']);      $pdf->SetDirectionality('rtl');         // $mpdf->setLogger($logger);       $pdf->SetDocTemplate($path,false);        $i=0;        while($i<=1000){          $pdf->AddPage('L','A','L','L','L',50,50,50,50,10,10);        $i++;        }        $pdf->WriteHTML('Hello World');          // Subsequent pages from logoheader.pdf will be inserted on all subsequent pages             //Make sure path exists           if (!file_exists($path)) {               mkdir($path, 0777);           }             $pdf->Output();      }  } 
Received answer to this question:
The best answer according to the author of the question:

This is because the library used to import the PDFs for mPDF (FPDI) can only read up to version 1.4 of the PDF specification. Anything higher than this is not supported and will generate the error you've noted.

There is a commercial parser for FPDI that does include full support reading later version of the PDF specification - 1.5 to 1.7 (the latest) - which you might find useful: https://www.setasign.com/products/fpdi-pdf-parser/details/