Hello Devs,

In this tutorial, we are going to learn how to create pdf in laravel 7.

Follow this step by step guide given below:

Step 1 : 

Install Laravel 7

composer create-project --prefer-dist laravel/laravel blog

Step 2 :

Install dompdf Package 

composer require barryvdh/laravel-dompdf


'providers' => [
'aliases' => [
	'PDF' => Barryvdh\DomPDF\Facade::class,

Step 3: 

Create Route routes/web.php


Step 4: 

Create Controller 

php artisan make:controller PdfController



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use PDF;

class PdfController extends Controller
    public function create()
    	$data = ['title' => 'Laravel 7 Generate PDF From View Example Tutorial'];
        $pdf = PDF::loadView('pdf', $data);
        return $pdf->download('Rathorji.pdf');

Step 5: 

Create View File resources/views/pdf.blade.php

<! DOCTYPE html>
	<title>Laravel 7 Generate PDF From View Example Tutorial - Rathorji</title>
    <h1>Welcome to Rathorji.in - {{ $title }}</h1>
    <p>Rathorji Blog provides you latest Code Tutorials on PHP, Laravel, Codeigniter,
    JQuery, Node js, React js, Vue js, PHP, and Javascript. Mobile technologies like Android,
    React Native, Ionic etc.</p>

Run this command:

php artisan serve

Open this URL:


I hope this example helps you.