2

I am getting an error when trying to generate a PDF in Craft Commerce.

The error is:

Undefined index: (/srv/data/web/vhosts/www.nihonshu-sake.lu/craft/plugins/commerce/vendor/dompdf/dompdf/lib/Cpdf.php:3855) $font = $this->fonts[$this->currentFont];

1 Answer 1

2

Craft Commerce 1.x uses the Dompdf package to generate PDFs.

The issue is likely a font cache issue, Dompdf caches an index about all fonts. Removing the cache indexes should fix the issue. Remove:

craft/plugins/commerce/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.php

This is as mentioned in the migration guide and occurs because Craft Commerce has gone from Dompdf 0.6 to 0.8:

https://github.com/dompdf/dompdf/wiki/Migration-Guide

The class naming conventions required a change to the dompdf_font_family_cache.php file. Though we have attempted to accommodate this change your first step when encountering bugs (if you don't know where to start) might be to reset your font directory (i.e. remove custom font files and the related font metrics files, and remove the non-dist, generated, font family cache file).

First try removing the dompdf_font_family_cache.php as mentioned above. If that doesn't work try removing all files they list above from the same folder. I think that includes all .afm. The directory should end up looking something like the original: https://github.com/dompdf/dompdf/tree/master/lib/fonts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.