By Hardik Savani July 24, 2021 Category : LaravelVideo Player is loading.PlayUnmuteLoaded: 0.00%FullscreenHi,
In this quick example, let's see laravel convert pdf to image example. i would like to show you laravel convert pdf to image. We will use laravel pdf to image convert. if you want to see example of how to convert pdf to image in laravel then you are a right place.
Sometime we may need to convert pdf file to image in php laravel. If you need then i will give you simple example of how to convert pdf to image in laravel 6, laravel 7, laravel 8 and laravel 9 version.
we will use php imagick extension for convert pdf to image file. you must have to install imagick extension for pdf and give to permission. let's see step by step installation and configuration for imagick.
Step 1: Install imagick extension
in first step, we need install imagick extension for php, so let's install it and give permission as bellow:
<?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\DemoController; /*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/Route::get('convert-pdf-to-image', [DemoController::class, 'index']);
<?php namespace App\Http\Controllers; use Illuminate\Http\Request;use Imagick; class DemoController extends Controller{ /** * Write code on Method * * @return response() */ public function index() { $imagick = new Imagick(); $imagick->readImage(public_path('dummy.pdf')); $saveImagePath = public_path('converted.jpg'); $imagick->writeImages($saveImagePath, true); return response()->file($saveImagePath); }}