A Kimai plugin to use Dompdf as PDF renderer (in place of MPdf)
- Requires Kamai 2
- PDFs created by dompdf
- Much smaller PDFs
- Improved support for CSS 2.1 in templates
The bundle is in early stages, but appears to be working well. The kimai-v1 branch has been tested and used with Kimai 1.30.10 (stable), which is currently what's installed with the kimai/kimai2:fpm docker image.
Page numbering in templates can either be positioned manually, with x and y co-ordinates, using in an inline php script. See the script at the bottom of the provided default template.
Alternatively, use css to insert the current page number, and the string
__TPC__ will be replaced with the total page count. This is how the provided
awesome template does it.
Right-alignment to the page margins is tricky though, as __TPC__ is the
string that will be right-aligned (not the total page count number, which is
what is finally shown).
First unzip the plugin into to your Kimai plugins directory:
unzip DompdfRendererBundle-x.x.zip -d <kimai path>/var/plugins/And then reload Kimai:
bin/console kimai:reloadDompdfRendererBundle has one dependency (i.e. dompdf), which I thought should be installed automatically with the above command, but for some reason dompdf wasn't installing automatically for me. So, while in the top level folder, run the following command to install dompdf:
composer require dompdf/dompdfThe plugin should appear, and will now be used as the PDF renderer instead of MPdf.
To disable the dompdf backend, either:-
- Edit Resources/config/dompdf_config.yaml, changing the
renderervalue tompdf(or anything other thandompdf) - Set the environment variable
KIMAI_PDF_RENDERERto something (anything other thandompdf).
Then, reload Kimai again:
bin/console kimai:reloadNew twig templates can be added to /Resources/invoices. Two examples are
provided, one based on Kimai's default template, and the other being a heavily
modified version of the din5008 invoice template, obtained from the
kimai/invoice-templates github repository.
An invoice generated from the kimai demo data, and using a fake logo from the pigment/fake-logo github repository is shown below and full pdf available in the examples directory.
