Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

OG-Tyavyar-Jnr's avatar

I have a pdf document in my projecI started having this message: 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)

<?php

namespace App\Http\Controllers;

use Carbon\Carbon;
use setasign\Fpdi\Fpdi;
// use App\Http\Requests\CertificatesRequest;
use App\Models\Certificate;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;

class FillPDFController extends Controller


{
    public function process($id)

    {
        $certificate = Certificate::find($id);
        $outputfile = public_path().'dcc.pdf';
        $this->fillPDF(public_path().'/master/dcc.pdf',$outputfile,$certificate->name,$certificate->certificate_num);
       return response()->file($outputfile);
    }

    public function fillPDF($file,$outputfile,$nama,$certificate_num)
    {

        $rows = Certificate::orderBy('created_at','desc')->get();
        foreach ($rows as $row){
            "Certificate number for ID {$row->id} is: {$row->certificate_num}<br>";
        }
         {
        $fpdi = new FPDI;
        $fpdi->setSourceFile($file);
        $template = $fpdi->importPage(1);
        $size = $fpdi->getTemplateSize($template);
        $fpdi->AddPage($size['orientation'],array($size['width'],$size['height']));
        $fpdi->useTemplate($template);
        $top =98;
        $right = 105;
        $nama = $nama;
        $fpdi->SetFont("helvetica","",25);
        $fpdi->SetTextColor(25,26,25);
        $fpdi->Text($right,$top,$nama);
        $fpdi->ln();
       
        $top =30;
        $right = 232;
        $fpdi->SetFont("helvetica","",11);
        $fpdi->Text($right,$top,$certificate_num);

        $todayDate = Carbon::now()->format('F j, Y');
         //dd($todayDate);
        $top = 186;
        $right = 66;
        $fpdi->SetFont("helvetica","",12);
        $fpdi->Text($right,$top,$todayDate);


       //get the QRcode PNG  u generated
        $qrImage=storage_path('/app/public/img/qr-code/1680513790.png');

        // insert image at position x,y,w,h
        $fpdi->Image($qrImage,234,55,36,30);
        
        
        return $fpdi->Output($outputfile,'F');
        
    }

    }
    

    }



0 likes
1 reply
LaryAI's avatar
Level 58

The error message "This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI" indicates that the PDF file being imported by FPDI is using a compression technique that is not supported by the free parser. To resolve this issue, you can try using a different PDF parser that supports the compression technique used by the PDF file. Alternatively, you can try converting the PDF file to a different format that is supported by FPDI.

If you want to use a different PDF parser, you can try using the commercial version of FPDI, which supports a wider range of compression techniques. Alternatively, you can try using a different PDF parsing library, such as TCPDF or mPDF, which may support the compression technique used by the PDF file.

If you want to convert the PDF file to a different format, you can try using a tool like Ghostscript or Adobe Acrobat to convert the PDF file to a format that is supported by FPDI, such as a non-compressed PDF or an image format like PNG or JPEG.

Note that the specific solution will depend on the compression technique used by the PDF file and the requirements of your application.

Please or to participate in this conversation.