Laravel 8 Generate PDF with Graph Tutorial
Laravel 8 – produce a PDF with an example graph We'll show you how to make a pdf with a graph in the Laravel 8 app in this tutorial. The term "graph" refers to a diagram that depicts a relationship between two or more things. Making a sequence of bars on graphing paper is an example of a graph. A graph is a diagram that depicts the relationships between two or more objects. Pie charts are one type of graphs. This tutorial will walk you through the process of creating a pdf with graph in a Laravel application, step by step.
Table of Content
- Install wkhtmltopdf Software - Install Laravel 8 App - Install mikehaertl/phpwkhtmltopdf - Add Routes - Create Controller by Command - Create Blade View - Run Development Server - Test This App
Step 1 – Install wkhtmltopdf Software
To begin, run the following command on your web server to install the wkhtmltopdf package. This programme will be installed on your webservers using the commands below: For Ubuntu: sudo apt install wkhtmltopdf For Windows: You must click on the below link and download the exe file. Then do the following https://wkhtmltopdf.org/
Step 2 – Install Laravel 8 App
To install the latest version of the Laravel application, use the following command. So, open your terminal OR command prompt and type in the following: composer create-project --prefer-dist laravel/laravel blog
Step 3 – Install mikehaertl/phpwkhtmltopdf
Install the mikehaertl/phpwkhtmltopdf package in this step. So, open your command prompt once more and type in the following command: composer require mikehaertl/phpwkhtmltopdf
Step 4 – Add Routes
Open the web.php file in this phase and add the following routes to it: routes/web.php use AppHttpControllersGraphPdfController; Route::get('graph', ); Route::get('download', )->name('download'); The very first route will display a graph on a web page, while the second will allow you to download a pdf file.
Step 5 – Create Controller by Command
Open your command prompt and type the following command to build a controller called GraphPDFcontroller: php artisan make:controller GraphPdfController This command will generate GraphPdfController.php as a controller. After that, navigate to app/Http/Controllers and open GraphPdfController.php. Then, in your controller file, update the following methods: Read the full article








