Today our leading theme is laravel 7 producing pdf file. I would like to show you how to produce a pdf in laravel 7. you will learn laravel 7 create a pdf by viewing. I'll show you about save as pdf in laravel 7.

As you know, a few days ago laravel 7 was released. so i plan to add a tutorial by creating a pdf file with laravel 7.

PDF is one of the basic requirements when working with an erp level project or e commerce website. we may need to create a pdf file of the report or invoice etc. So, here I am going to give you a simple example of making a pdf file with laravel.

You just need to follow the compelling step to create a pdf file and you can download it. So let's take bold steps.

Install Laravel 7

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

Install dompdf Package

composer require barryvdh/laravel-dompdf

After open the config/app.php and following the some code.

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

Add Route : routes/web.php


Add Controller : app/Http/Controllers/PDFController.php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use PDF;
class PDFController extends Controller
    public function generatePDF()
        $data = ['title' => 'Welcome to'];
        $pdf = PDF::loadView('myPDF', $data);
        return $pdf->download('howtowebcode.pdf');

Create View File : resources/views/myPDF.blade.php

<!DOCTYPE html>
	<h1>Welcome to - {{ $title }}</h1>
	<p>How to web code is Best Portal to Learn Technologies and best codes. How to web code provide a collection of tutorials about PHP, Codeigniter Framework, Laravel Framework, Mysql Database, Bootstrap Front-end Framework, Jquery etc. You will find the best example an article about of the PHP Language. How to web code is optimized for learning, testing, and training. Our How to web code website helpful to you can create your own website or build career in website development.</p>