PHPackages                             renatio/dynamicpdf-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. renatio/dynamicpdf-plugin

ActiveOctober-plugin[PDF &amp; Document Generation](/categories/documents)

renatio/dynamicpdf-plugin
=========================

October HTML to PDF converter using dompdf library.

v8.0.3(9mo ago)3013.5k23[2 issues](https://github.com/mplodowski/dynamicpdf-plugin/issues)3MITPHP

Since Dec 7Pushed 9mo ago5 watchersCompare

[ Source](https://github.com/mplodowski/dynamicpdf-plugin)[ Packagist](https://packagist.org/packages/renatio/dynamicpdf-plugin)[ Docs](https://octobercms.com/plugin/renatio-dynamicpdf)[ RSS](/packages/renatio-dynamicpdf-plugin/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (17)Used By (3)

Dynamic PDF Plugin
==================

[](#dynamic-pdf-plugin)

**Demo URL:**

**Login:** dynamicpdf

**Password:** dynamicpdf

This plugin allows developers to create and edit PDF templates with a simple user interface.

HTML to PDF converter uses [dompdf](https://github.com/dompdf/dompdf) library.

Plugin uses dompdf wrapper for Laravel [barryvdh/laravel-dompdf](https://github.com/barryvdh/laravel-dompdf).

Like this plugin?
-----------------

[](#like-this-plugin)

If you like this plugin, give this plugin a Like or Make donation with [PayPal](https://www.paypal.me/mplodowski).

My other plugins
----------------

[](#my-other-plugins)

Please check my other [plugins](https://octobercms.com/author/Renatio).

Support
-------

[](#support)

Please use [GitHub Issues Page](https://github.com/mplodowski/dynamicpdf-plugin/issues) 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.

Icon made by [Darius Dan](https://www.flaticon.com/authors/darius-dan)from [www.flaticon.com](https://www.flaticon.com/).

Documentation
=============

[](#documentation)

Installation
------------

[](#installation)

There are couple ways to install this plugin.

1. Use `php artisan plugin:install Renatio.DynamicPDF` command.
2. Use `composer require renatio/dynamicpdf-plugin` in project root. When you use this option you must run `php artisan october:migrate` after installation.

PDF content
-----------

[](#pdf-content)

PDF can be created in October using either PDF views or PDF templates. A PDF view is supplied by plugin in the file system in the **/views** directory. Whereas a PDF template is managed using the back-end interface via *Settings &gt; PDF &gt; PDF Templates*. All PDFs templates support using Twig for markup.

PDF views must be registered in the Plugin registration file with the `registerPDFTemplates` and `registerPDFLayouts`method. This will automatically generate a PDF template and layout and allows them to be customized using the back-end interface.

PDF layouts views
-----------------

[](#pdf-layouts-views)

PDF layouts views reside in the file system and the code used represents the path to the view file. For example PDF layout with the code **author.plugin::pdf.layouts.default** would use the content in following file:

```
plugins/                 stream();

```

### UTF-8 support

[](#utf-8-support)

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

```

```

If you have problems with foreign characters than try to use **DejaVu Sans** font family.

### Page breaks

[](#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;
}

Page 1

Page 2

```

### Open basedir restriction error

[](#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')
    ->setLogOutputFile(storage_path('temp/log.htm'))
    ->stream();

```

### Embed image inside PDF template

[](#embed-image-inside-pdf-template)

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

For this to work you must set `isRemoteEnabled` option.

```
return PDF::loadTemplate('renatio::invoice', ['file' => $file])
    ->setIsRemoteEnabled(true)
    ->stream();

```

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.

### Download PDF via Ajax response

[](#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.

### Page numbers

[](#page-numbers)

Page numbers can be generated using PHP. Inline PHP is disabled by default, because it can be a security risk. You can enable inline PHP using `setIsPhpEnabled` method.

```
return PDF::loadTemplate('renatio::invoice')
    ->setIsRemoteEnabled(true)
    ->setIsPhpEnabled(true)
    ->stream();

```

After that you must place following code before closing `` tag of the layout file.

```

    if (isset($pdf)) {
        $size = 9;
        $color = [0,0,0];

        $font = $fontMetrics->getFont('Open Sans');
        $textHeight = $fontMetrics->getFontHeight($font, $size);
        $width = $fontMetrics->getTextWidth('Page 1 of 2', $font, $size);

        $foot = $pdf->open_object();

        $w = $pdf->get_width();
        $h = $pdf->get_height();

        $y = $h - $textHeight - 13;

        $pdf->close_object();
        $pdf->add_object($foot, 'all');

        $text = "Page {PAGE_NUM} of {PAGE_COUNT}";

        // Center the text
        $pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);
    }

```

Examples
--------

[](#examples)

### Demo examples

[](#demo-examples)

There is a console command that will enable demo templates and layouts.

```
php artisan dynamicpdf:demo

```

To disable demo run following command:

```
php artisan dynamicpdf:demo --disable

```

The first example shows invoice with custom font and image embed.

The second example shows usage of header &amp; footer, page break, page numbers and full background image.

### Render PDF in browser

[](#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

[](#download-pdf)

```
use Renatio\DynamicPDF\Classes\PDF;

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

```

### Fluent interface

[](#fluent-interface)

You can chain the methods:

```
return PDF::loadTemplate('renatio::invoice')
    ->save('/path-to/my_stored_file.pdf')
    ->stream();

```

### Change paper size and orientation

[](#change-paper-size-and-orientation)

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

```

Available [paper sizes](https://github.com/dompdf/dompdf/blob/master/src/Adapter/CPDF.php#L40).

### PDF on CMS page

[](#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();
}

```

### Header and footer on every page

[](#header-and-footer-on-every-page)

```

    @page { margin: 100px 25px; }
    header { position: fixed; top: -60px; left: 0px; right: 0px; background-color: lightblue; height: 50px; }
    footer { position: fixed; bottom: -60px; left: 0px; right: 0px; background-color: lightblue; height: 50px; }
    p { page-break-after: always; }
    p:last-child { page-break-after: never; }

  header on each page
  footer on each page

    page1
    page2

```

### Using custom fonts

[](#using-custom-fonts)

Plugin provides "Open Sans" font, which can be imported in Layout CSS section.

```
@font-face {
    font-family: 'Open Sans';
    src: url({{ 'plugins/renatio/dynamicpdf/assets/fonts/OpenSans-Regular.ttf'|app }});
}

@font-face {
    font-family: 'Open Sans';
    font-weight: bold;
    src: url({{ 'plugins/renatio/dynamicpdf/assets/fonts/OpenSans-Bold.ttf'|app }});
}

@font-face {
    font-family: 'Open Sans';
    font-style: italic;
    src: url({{ 'plugins/renatio/dynamicpdf/assets/fonts/OpenSans-Italic.ttf'|app }});
}

@font-face {
    font-family: 'Open Sans';
    font-style: italic;
    font-weight: bold;
    src: url({{ 'plugins/renatio/dynamicpdf/assets/fonts/OpenSans-BoldItalic.ttf'|app }});
}

body {
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
}

```

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance57

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 87.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~117 days

Recently: every ~182 days

Total

16

Last Release

270d ago

Major Versions

v4.0.8 → v5.0.12021-08-12

v5.0.5 → v6.0.02022-06-07

v6.0.1 → v7.0.02022-10-13

v7.1.2 → v8.0.12025-07-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6774277?v=4)[Michał Płodowski](/maintainers/mplodowski)[@mplodowski](https://github.com/mplodowski)

---

Top Contributors

[![mplodowski](https://avatars.githubusercontent.com/u/6774277?v=4)](https://github.com/mplodowski "mplodowski (143 commits)")[![gergo85](https://avatars.githubusercontent.com/u/2959112?v=4)](https://github.com/gergo85 "gergo85 (6 commits)")[![kocholes](https://avatars.githubusercontent.com/u/13872365?v=4)](https://github.com/kocholes "kocholes (5 commits)")[![purposebuiltscott](https://avatars.githubusercontent.com/u/19328236?v=4)](https://github.com/purposebuiltscott "purposebuiltscott (2 commits)")[![samuelpatro](https://avatars.githubusercontent.com/u/3110002?v=4)](https://github.com/samuelpatro "samuelpatro (2 commits)")[![vojtasvoboda](https://avatars.githubusercontent.com/u/374917?v=4)](https://github.com/vojtasvoboda "vojtasvoboda (2 commits)")[![TimFoerster](https://avatars.githubusercontent.com/u/7849550?v=4)](https://github.com/TimFoerster "TimFoerster (1 commits)")[![MatissJanis](https://avatars.githubusercontent.com/u/886567?v=4)](https://github.com/MatissJanis "MatissJanis (1 commits)")[![LarryBarker](https://avatars.githubusercontent.com/u/28734844?v=4)](https://github.com/LarryBarker "LarryBarker (1 commits)")

---

Tags

octobercms-pluginphplaravelpdfdompdfoctobercmsoctobercms-plugin

### Embed Badge

![Health badge](/badges/renatio-dynamicpdf-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/renatio-dynamicpdf-plugin/health.svg)](https://phpackages.com/packages/renatio-dynamicpdf-plugin)
```

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.4k99.4M384](/packages/barryvdh-laravel-dompdf)[rainlab/pages-plugin

Pages plugin for October CMS

12253.8k4](/packages/rainlab-pages-plugin)[rainlab/user-plugin

User plugin for October CMS

11955.0k15](/packages/rainlab-user-plugin)[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

172166.2k](/packages/mostafaznv-pdf-optimizer)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
