Description
I have a pdf template in my project so if am trying to download i got the below error message
View Code
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use setasign\Fpdi\Fpdi;
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');
}
}
}
The problem is in the pdf version, by downgrading the PHP version it will work.
Solved
0 Likes 2 Comments
OG Designs Author
I am yet to solve the problem. I am still struggling to solve the problem
commented 1 year ago
Hadayat Niazi Super Admin
Hadayat Niazi Super Admin
Hadayat Niazi Super Admin
Yes, we got your query, Our team will fix your issue very soon. Thank you
commented 1 year ago
For more information please visit the below link. https://stackoverflow.com/questions/12154190/fpdf-error-this-document-testcopy-pdf-probably-uses-a-compression-technique-w