Product support

Visit this product's website for support.


Dynamic PDF plugin

October HTML to PDF converter using dompdf library.

Plugin uses dompdf wrapper for Laravel barryvdh/laravel-dompdf.


  • Handles most CSS 2.1 and a few CSS3 properties, including @import, @media & @page rules
  • Supports most presentational HTML 4.0 attributes
  • Supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
  • Supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling
  • Image support (gif, png (8, 24 and 32 bit with alpha channel), bmp & jpeg)
  • No dependencies on external PDF libraries, thanks to the R&OS PDF class
  • Inline PHP support
  • Basic SVG support


Please use GitHub Issues Page to report any issues with plugin.

Reviews should not be used for getting support or reporting bugs, if you need support please use the Plugin support link.

Like this plugin?

If you like this plugin, give this plugin a Like or Make donation with PayPal.

Templates list


There are couple ways to install this plugin.

  1. Use October Marketplace and Add to project button.
  2. Use October backend area Settings > System > Updates & Plugins > Install Plugins and type Renatio.DynamicPDF.
  3. Use php artisan plugin:install Renatio.DynamicPDF command.
  4. Use composer require renatio/dynamicpdf-plugin in project root. When you use this option you must run php artisan october:up after installation.

Fourth option should be used only for advanced users.


Plugin will register menu item called PDF, which allow you to manage PDF layouts and templates.

Layouts define the PDF scaffold, that is everything that repeats on a PDF, such as a header and footer. Each layout has unique code, optional background image, HTML content and CSS content. Not all CSS properties are supported, so check CSSCompatibility.

Templates define the actual PDF content parsed from HTML. The code specified in the template is a unique identifier and cannot be changed once created.

You can use Twig in layouts and templates.

Plugin supports using CMS partials and filters inside template and layout markup.


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:

    ->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: "{appdirectory}/storage/fonts/" (available in config/dompdf.php)_
  • fontCache: "{appdirectory}/storage/fonts/" (available in config/dompdf.php)_
  • chroot: "{appdirectory}" (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"


Method Description
loadTemplate($code, array $data = [], $encoding = null) Load backend template
loadLayout($code, array $data = [], $encoding = null) Load backend layout
loadHTML($string, $encoding = null) Load HTML string
loadFile($file) Load HTML string from a file
parseTemplate(Template $template, array $data = []) Parse backend template using Twig
parseLayout(Layout $layout, array $mergeData = []) Parse backend layout using Twig
getDomPDF() Get the DomPDF instance
setPaper($paper, $orientation = 'portrait') Set the paper size and orientation (default A4/portrait)
setWarnings($warnings) Show or hide warnings
output() Output the PDF as a string
save($filename) Save the PDF to a file
download($filename = 'document.pdf') Make the PDF downloadable by the user
stream($filename = 'document.pdf') Return a response with the PDF to show in the browser

All methods are available through Facade class Renatio\DynamicPDF\Classes\PDF.

Tip: Background image

To display background image added in layout use following code:

<body style="background: url({{ background_img }}) top left no-repeat;">

Background image should be 96 DPI size (793 x 1121 px).

Tip: UTF-8 support

In your layout, set the UTF-8 meta tag in head section:

<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>

Tip: Open_basedir restriction error

On some hosting providers there were reports about open_basedir restriction problems with log file. You can change default log file destination like so:

return PDF::loadTemplate('renatio::invoice')
    ->setOptions(['logOutputFile' => storage_path('temp/log.htm')])

Tip: Embed image inside PDF template

You can use absolute path for image eg. http://app.dev/path_to_your_image.

For this to work you must set isRemoteEnabled option.

return PDF::loadTemplate('renatio::invoice', ['file' => $file])
    ->setOptions(['isRemoteEnabled' => true])

I assume that $file is instance of October\Rain\Database\Attach\File.

Then in the template you can use following example code:

{{ file.getPath }}

{{ file.getLocalPath }}

{{ file.getThumb(200, 200, {'crop' => true}) }}

For retrieving stylesheets or images via http following PHP setting must be enabled allow_url_fopen.

When allow_url_fopen is disabled on server try to use relative path. You can use October getLocalPath function on the file object to retrieve it.

Tip: Download PDF via Ajax response

OctoberCMS ajax framework cannot handle this type of response.

Recommended approach is to save PDF file locally and return redirect to PDF file.


After installation there will an example PDF invoice document, which will show, how you can structure HTML and CSS.

Render PDF in browser

use Renatio\DynamicPDF\Classes\PDF; // import facade


public function pdf()
    $templateCode = 'renatio::invoice'; // unique code of the template
    $data = ['name' => 'John Doe']; // optional data used in template

    return PDF::loadTemplate($templateCode, $data)->stream('download.pdf');

Where $templateCode is an unique code specified when creating the template, $data is optional array of twig fields which will be replaced in template.

In HTML template you can use {{ name }} to output John Doe.

Download PDF

use Renatio\DynamicPDF\Classes\PDF;


public function pdf()
    return PDF::loadTemplate('renatio::invoice')->download('download.pdf');

Fluent interface

You can chain the methods:

return PDF::loadTemplate('renatio::invoice')

Change orientation and paper size

return PDF::loadTemplate('renatio::invoice')
    ->setPaper('a4', 'landscape')

Available paper sizes.

PDF on CMS page

To display PDF on CMS page you can use PHP section of the page like so:

use Renatio\DynamicPDF\Classes\PDF;

function onStart()
    return PDF::loadTemplate('renatio::invoice')->stream();
  • Found the plugin useful on 10 May, 2019

    Hey Renatio, thanks for a good plugin. I've used it before without issue. However, the project I'm working on now does not use the CMS module, which is disabled and there is no theme installed. After installing this plugin with composer, I am getting a cms active theme not set error. I made an issue in the repo and would appreciate any assistance in getting it working without the CMS module loaded. Thanks!

  • Found the plugin useful on 11 May, 2018

    Well Done Mate! Good Job!!!

    I used DOMPDF Lib in codeigniter couple of years ago.it was really a headache.

    in this plugin i see all the problems have been sorted out which i faced previously.

    Thanks For Sharing!

  • Found the plugin useful on 7 May, 2018

    Awesome plugin! Just faced the issue with encoding. Couldn't get cyrillic letters to show properly just like in Kenny Heisher review comment. Problem is that dompdf vendor got too little font collection. But for those who want cyrillic symbols you can use font-family: DejaVu Sans; that solved my problem

  • Found the plugin useful on 22 Mar, 2018

    Useful App Converted to a Comment System

    I spent time building a system that can run as a comment form because I was tired of looking for one outside of the forum topic. Thanks!

    • 1.Create a page for the form
    • 2.Create a partial that is going to load the back-end data
    • 3.Set the where() method to specify what data is being queried
    • 4.Add the ajax handler to refresh partial after submission to the component
    • 5.Add the php call to the onRefreshTime()

    1. Page Markup: Summarized

    <div id="magicForms">{% partial 'testing/magicform' %}</div> <form data-request="{{ genericForm2 }}::onFormSubmit">...</form>

    2. Partial Markup: Summarized

    <ul> {% for record in records %} <li><strong>{{ record.form_data_arr.name }}:</strong> {{ record.form_data_arr.comment }}</li> {% endfor %} </ul>

    3. Parital Code: This is where the the collection methods get handy. Using the where() method I can query for the specific group. Here I am searching for the forms with 'group' and 'testing-comments'; the reverse is to put the newest comment on top.

    use \Martin\Forms\Models\Record as FormsRecords; function onStart() { $comments = FormsRecords::all(); $this['records'] = $comments->where('group', 'testing-comments')->reverse(); }

    4. Generic AJAX Form Component: Add this in More Settings -> JS on Success

    jQuery(document).ready(function($) { setInterval(function () { $.request('onRefreshTime', { update: { 'testing/magicform' : '#magicForms' } }) }, 300); });

    5. Page Code: This is needed for the javascript to call the onRefreshTime.

    function onRefreshTime() { return [ '#magicForms' => $this->renderPartial('testing/magicform') ]; }

  • Found the plugin useful on 27 Jul, 2017

    well... the worst plugin EVER!!! (joke) THANK YOU MAN :D

  • Found the plugin not useful on 14 Jul, 2017

    Not working with rainlab translate

  • author

    Replied on 17 Jul, 2017


    I'm so sorry it doesn't support external plugin like RainLab.Translate, but tell me why it should?

    Don't you think this is a new feature than can be added on request?

    You added request on GitHub and 10 minutes later you gave this plugin a negative review, because it doesn't meet all your requirements. I don't see that I wrote in documentation that it supports Translate plugin. It's open source project and you're welcome to make pull request for new features. If you don't have skill to make it, than just leave it to me.

    There is one simple rule here: if you don't like this plugin or it doesn't suit your task, then don't use it. It's free plugin and I spent my free time to make it and support.

    This plugin has many positive reviews from people that thinks it was usefull for them, so your review doesn't make a difference here. Imagine situation when fresh October developer make his first plugin and share it with you. Plugin works fine, have no bugs and make a job done. Then you use it and it looks like it doesn't support RainLab.Translate plugin and you write first negative review. This can make a huge impact on newcomer and discourage him from creating new plugins at all. Please think what you're doing and appreciate someone else work.


  • Found the plugin useful on 14 Jun, 2017

    Work like a charm. Thanks for the great job

  • Found the plugin useful on 5 May, 2017

    Thank you for the Plugin!

  • Found the plugin useful on 14 Apr, 2017

    Does the job! Thumbs up

  • Found the plugin useful on 28 Feb, 2017

    Thanks for Great plugin. But I am stucked with using UTF-8 font.

    Some people said I should run "php load_font.php FontName /path/to/font.ttf" (http://stackoverflow.com/questions/8968627/how-to-make-dompdf-support-unicode-font-step-by-step) But I cannot find the file "load_font.php" in this plugin. Please help me.

  • Found the plugin useful on 25 Sep, 2016

    Very useful!! Easy to use and did precisely what I needed it for!

  • Found the plugin useful on 12 Jul, 2016

    Nice plugin :-)

    I'm using window 7 and I had full permission but when I use preview button on templates backend it so message.

    unlink(C:\Users\lvthu\AppData\Local\Temp/04b854edea2a8e08d8007d212360ace1): Permission denied

    please help me.

  • author

    Replied on 12 Jul, 2016

    Thanks for the review :)

    This is not the place for support topic. Please use support area for this: https://github.com/mplodowski/DynamicPDF/issues

  • Found the plugin useful on 13 Jun, 2016

    Great plugin and outstanding support! Thank you very much!

  • Found the plugin useful on 8 May, 2016

    Nice plugin :-)

    If the demo template throws this error : DOMNode::cloneNode(): ID header already defined, it can be fixed by changing all id's in the template and layout into class, and changing the css accordingly.

  • author

    Replied on 9 May, 2016

    Thanks for the review :) This is now fixed in version 1.1.5.

  • Found the plugin useful on 11 Dec, 2015


  • Found the plugin useful on 18 Sep, 2015

    Thanks! I find this really useful

  • Found the plugin useful on 20 Aug, 2015

    Perfect plugin. The best side is it supports Turkish characters :)

    Thank you!

  • Found the plugin useful on 3 Jul, 2015

    You plugin is amazing.. From html to pdf... It gives you the power for reporting generation directly from OctoberCMS... It's a must-have plugin!!!

  • Found the plugin useful on 12 May, 2015

    I Love you ! Just perfect and great idea !


Allow to use CMS partials and filters.

May 06, 2018


Fix creating fonts directory

Dec 13, 2017


Add support for RainLab.Translate plugin

Sep 08, 2017


!!! Add support for Laravel 5.5.

Sep 07, 2017


Allow Laravel 5.5.

Jul 30, 2017


Fix open_basedir restriction on some hostings. Set isRemoteEnabled flag to allow absolute paths.

May 14, 2017


German language. Thanks to @TimFoerster.

May 14, 2017


Upgrade to DomPDF 0.8.

Mar 26, 2017


Database maintenance. Updated all timestamp columns to be nullable.

Mar 11, 2017


Upgrade to DomPDF 0.7.

Sep 10, 2016


!!! This is an important update that contains breaking changes.

Sep 10, 2016


Add preview HTML buttons.

Jun 12, 2016


!!! This is an important update that contains breaking changes.

May 28, 2016


UI improvements. Thanks to @kocholes.

May 09, 2016


Add Spanish and Spanish-Argentina locale. Thanks to @kocholes.

Apr 10, 2016


Add stream parameters and Czech locale. Thanks to @vojtasvoboda.

Apr 10, 2016


Minor changes.

Oct 05, 2015


Use Twig::parse() facade. Only update for October build 300 and above.

Oct 05, 2015


!!! Important update

Oct 05, 2015


Minor changes.

Sep 26, 2015


Initialize plugin.

May 10, 2015

Upgrading To 1.1.0

Plugin requires October build 300+.

Upgrading To 2.0.0

PDFTemplate::render() method was removed. Please switch to Renatio\DynamicPDF\Classes\PDF facade.

Upgrading To 2.1.0

Method setOrientation was removed. Use setPaper instead.

Upgrading To 2.1.1

Plugin requires Stable version of October and PHP >=5.5.9.

Upgrading To 3.0.0

Plugin requires OctoberCMS build 420+ with Laravel 5.5 and PHP >=7.0.