Home > OS >  How to convert image to pdf in Laravel?
How to convert image to pdf in Laravel?

Time:12-12

I created a image using imagettftext() function. Now I want to convert the resulted image to pdf. How can I achieve this?

header('content-type:application/octet-stream');
header("Content-Disposition: attachment; filename=certificate.jpg");

imagettftext($image,$font_size,$angle,$x_axis,$y_axis , $temp,$color,$font, $description);
        
imagejpeg($image);
$imagedestroy($image);

return $image;

CodePudding user response:

Use DomPDf Package. Add your Image in tag in laravel blade view file. then.

public function generatePDF()     
{
     $data = ['title' => 'Welcome to codeplaners.com'];     
     $pdf = PDF::loadView('myPDF', $data);     

     return $pdf->download('codeplaners.pdf');     
}
  • Related