inspiredminds/contao-pdf-generation

Allows you to create a PDF for a complete Contao page.

Fund package maintenance!
fritzmg

Installs: 123

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:contao-bundle

pkg:composer/inspiredminds/contao-pdf-generation

1.0.1 2025-12-12 13:19 UTC

This package is auto-updated.

Last update: 2026-01-22 11:38:55 UTC


README

Contao PDF Generation

This allows generating PDF files from regular Contao pages via the mPDF PDF generator.

Usage

First you need to create a PDF generation configuration. If you only need the default settings, the following would suffice for example:

contao_pdf_generation:
    configurations:
        my_pdf_config: ~

To use a PDF template, you can define the absolute path to the template like this for example:

contao_pdf_generation:
    configurations:
        my_pdf_config:
            pdf_template: '%kernel.project_dir%/files/pdf/my_pdf_template.pdf'

To integrate a custom font, you also need to define the absolute path to the font files:

contao_pdf_generation:
    configurations:
        my_pdf_config:
            fonts:
                default_font: foobar
                custom_fonts:
                    foobar:
                        R: '%kernel.project_dir%/files/pdf/Foobar-Regular.ttf'
                        B: '%kernel.project_dir%/files/pdf/Foobar-Bold.ttf'

check the output of config:dump-reference contao_pdf_generation for more options.

Next you will have to select a PDF generation configuration in your Contao page layout. You can find this in the Expert settings tab of your layout under PDF generation configuration. Only pages with a valid PDF generation configuration layout will be able to actually generate a PDF.

Next you will have to create a Generate PDF front end module in your theme. This module will output a form with a submit button that will trigger the PDF generation for the current page. Insert this module then either in your layout, or directly in your content somewhere.

Note

At the moment this extension is not compatible with the modern Twig page layouts of Contao 5.6+.