Create PDF document using Laravel 4

If you are developing a PHP based web application using Laravel and have some requirement to create PDF documents then you have very limited choice. I was searching some php library for generating PDF document and came across Dompdf. It’s a very simple Laravel library which can be used for generating PDF with lots of Options. You can create single or multiple PDF with page size, page orientation and can show / download PDF or return it as String.

First step is to download the Dompdf library. To download the project use one of the two approaches below.

1) Run the following command on your projects base directory.

I ran the above command and got the following output.

2) Edit composer.js file, add thujohn/pdf entry and run composer update to pull down the latest version of Pdf..

Following is my composer.js file I am sharing for your reference.

Second step is to open app.php file available in /app/config/app.php directory and add a new entry in providers array.

Now add the alias.

To test your PDF document, add following code in route.php

Now, we are all set. Open the browser and hit the URL you will see following Output.

Happy Coding 🙂

About the Author

has written 68 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2017 http://www.techzoo.org. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions