How to write text on existing PDF using Laravel, PHP?

/ By Arjun / Published on September 8, 2021

In this tutorial, you will learn how to write text to the existing pdf file in your Laravel application. We gonna write a simple PHP script to write text on a pdf 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 FillPDFController 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 http://localhost:8000/fill-data-pdfs

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.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x