In this tutorial, you will learn how to merge multiple pdf files in your Laravel application. We gonna write a simple PHP script to merge one or more pdf files (Laravel merge pdfs), into a single file. This script will work with any version of the Laravel framework.
We gonna install the
setasign\Fpdi library using composer and we’ll be using it to merge multiple pdf files into a single file.
Let’s start implementing it by installing the Laravel framework. This tutorial assumes that your computer already has PHP and Composer installed.
Step 1: Install Laravel framework with the composer.
you can create a new Laravel project by using Composer directly with the below command. After the application has been created, you may start Laravel’s local development server using the Artisan CLI’s serve command as shown below.
Step 2: Install FPDI Package using composer
Step 3: Open the existing controller file or create a new controller with
php artisan make:controller MergePDFController command and copy below methods to it.
Step 4: Define a route in web.php to test the functions.
Step5: Now start your application with
php artisan serve and access it at
You can see the output files at:
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.