Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


A DOMPDF Wrapper for Laravel

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star blank 374f33e4d622a2930833db3cbea26b5d03dc44961a6ecab0b9e13276d97d6682Star blank 374f33e4d622a2930833db3cbea26b5d03dc44961a6ecab0b9e13276d97d6682Star blank 374f33e4d622a2930833db3cbea26b5d03dc44961a6ecab0b9e13276d97d6682 (1 ratings)
Rated 2.0 out of 5
Subscribe to updates I use laravel-dompdf

Statistics on laravel-dompdf

Number of watchers on Github 1932
Number of open issues 268
Average time to close an issue 17 days
Main language PHP
Average time to merge a PR 4 days
Open pull requests 9+
Closed pull requests 8+
Last commit over 2 years ago
Repo Created about 7 years ago
Repo Last Updated over 2 years ago
Size 74 KB
Organization / Authorbarryvdh
Latest Releasev0.8.2
Page Updated
Do you use laravel-dompdf? Leave a review!
View open issues (268)
View laravel-dompdf activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating laravel-dompdf for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

DOMPDF Wrapper for Laravel 5

For Laravel 4.x, check the 0.4 branch!

Require this package in your composer.json and update composer. This will download the package and the dompdf + fontlib libraries also.

composer require barryvdh/laravel-dompdf


Laravel 5.x:

After updating composer, add the ServiceProvider to the providers array in config/app.php


You can optionally use the facade for shorter code. Add this to your facades:

'PDF' => Barryvdh\DomPDF\Facade::class,


After updating composer add the following lines to register provider in bootstrap/app.php


To change the configuration, copy the config file to your config folder and enable it in bootstrap/app.php:



You can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download.

$pdf = App::make('dompdf.wrapper');
return $pdf->stream();

Or use the facade:

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

You can chain the methods:

return PDF::loadFile(public_path().'/myfile.html')->save('/path-to/my_stored_file.pdf')->stream('download.pdf');

You can change the orientation and paper size, and hide or show errors (by default, errors are shown when debug is on)

PDF::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('myfile.pdf')

If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself.

Use php artisan vendor:publish to create a config file located at config/dompdf.php which will allow you to define local configurations to change some settings (default paper etc). You can also use your ConfigProvider to set certain keys.


The defaults configuration settings are set in config/dompdf.php. Copy this file to your own config directory to modify the values. You can publish the config using this command:

php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider"

You can still alter the dompdf options in your code before generating the pdf using this command:

PDF::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);

Available options and their defaults:

  • rootDir: {app_directory}/vendor/dompdf/dompdf
  • tempDir: /tmp (available in config/dompdf.php)
  • fontDir: {app_directory}/storage/fonts/ (available in config/dompdf.php)
  • fontCache: {app_directory}/storage/fonts/ (available in config/dompdf.php)
  • chroot: {app_directory} (available in config/dompdf.php)
  • logOutputFile: /tmp/log.htm
  • defaultMediaType: screen (available in config/dompdf.php)
  • defaultPaperSize: a4 (available in config/dompdf.php)
  • defaultFont: serif (available in config/dompdf.php)
  • dpi: 96 (available in config/dompdf.php)
  • fontHeightRatio: 1.1 (available in config/dompdf.php)
  • isPhpEnabled: false (available in config/dompdf.php)
  • isRemoteEnabled: true (available in config/dompdf.php)
  • isJavascriptEnabled: true (available in config/dompdf.php)
  • isHtml5ParserEnabled: false (available in config/dompdf.php)
  • isFontSubsettingEnabled: false (available in config/dompdf.php)
  • debugPng: false
  • debugKeepTemp: false
  • debugCss: false
  • debugLayout: false
  • debugLayoutLines: true
  • debugLayoutBlocks: true
  • debugLayoutInline: true
  • debugLayoutPaddingBox: true
  • pdfBackend: CPDF (available in config/dompdf.php)
  • pdflibLicense: ""
  • adminUsername: user
  • adminPassword: password

Tip: UTF-8 support

In your templates, set the UTF-8 Metatag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

Tip: Page breaks

You can use the CSS page-break-before/page-break-after properties to create a new page.

.page-break {
    page-break-after: always;
<h1>Page 1</h1>
<div class="page-break"></div>
<h1>Page 2</h1>


This DOMPDF Wrapper for Laravel is open-sourced software licensed under the MIT license

laravel-dompdf open issues Ask a question     (View All Issues)
  • over 3 years Need help to get high pdf automatically adapts to the content.
  • over 3 years Fatal Error: Box property calculation requires containing block width
  • over 3 years html/css not rendering properly
  • over 3 years Undefined variable from other Controller
  • over 3 years Cannot set file name
  • over 3 years Fresh installation laravel 5.2 throws this error
  • over 3 years Erro no work in laravel 5.3 "->setOrientation('landscape');"
  • almost 4 years CSS Float doesn't work
  • almost 4 years fopen(/var/www/public_html/woods/storage/fonts//5ab413ede0c0d14abbb48febee3bfdfb.ufm): failed to open stream: No such file or directory
  • almost 4 years handleError('8', 'Undefined index: ', 'url/vendor/dompdf/dompdf/lib/Cpdf.php', '3547', array('size' => '12')) in
  • almost 4 years DOMPDF_TEMP_DIR configuration ignored?
  • almost 4 years Maximum execution time exceeded
  • almost 4 years Maximum execution time of 60 seconds exceeded on `php artisan serve`
  • almost 4 years Trying to render Lavacharts into PDF
  • almost 4 years Failed to load PDF document
  • almost 4 years class dompdf does not exist in laravel 4.2
  • almost 4 years Default paper from config seems not to be working anymore since upgrade from 0.6 zo 0.7 (Letter instead of A4 as per config)
  • almost 4 years Laravel Read.me Version Wrong
  • almost 4 years Class dompdf.wrapper does not exist
  • almost 4 years Font issue
  • almost 4 years Combine orientation page
  • almost 4 years Could not install Laravel-dompdf
  • almost 4 years Laravel 5.3.2 : Cannot use Facade
  • almost 4 years Your requirements could not be resolved to an installable set of packages. ---- Whats wrong ?
  • almost 4 years laravel 5.3 support
  • almost 4 years Installation
  • almost 4 years Call to undefined method Page_Frame_Decorator::add_line()
  • almost 4 years Second and others call to underlying PDF object cause uglify content for utf-8 fonts
  • about 4 years merge two pdf
  • about 4 years How to set PDF to print with no scaling ?
laravel-dompdf open pull requests (View All Pulls)
  • Adding setPublicPath method to change the base path
  • Uses Laravel's filesystem for save method (saving PDF file)
  • dompdf_config workaround if workbench vendor
  • make the service provider defered and add a custom font load command
  • Fix a few grammar/typos in config file
  • Added possibility to password protect the PDF
  • Append options to existing config
  • add passworded on opening file
  • Trailing slash isn't required and causes errors
laravel-dompdf questions on Stackoverflow (View All Questions)
  • Laravel 5.1 - barryvdh/laravel-dompdf, PDF file download not working properly
  • Laravel Dompdf generate pdf Error
  • Laravel DOMPDF not generating HTML pdf file with dynamic data
  • laravel dompdf - issue with font
  • laravel-dompdf how to get multiple records into the data array
  • Laravel-dompdf (0.4) does not display remote images
  • Laravel 5.1 - barryvdh/laravel-dompdf PDF Generation Error
  • Laravel DomPdf dont support UTF-8
  • Laravel dompdf errors
  • laravel-dompdf - Japanese IPAex gothic font is not working
  • How to insert page number using barryvdh/laravel-dompdf
  • Laravel-dompdf slow generate pdf
  • Laravel dompdf not accepting Tahoma font
  • laravel dompdf get pagenumber in view
  • utf-8 support for barryvdh/laravel-dompdf on laravel 4
  • DOMPDF: Image not readable or empty. (with barryvdh/laravel-dompdf)
laravel-dompdf list of languages used
Other projects in PHP