1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Fix a PDF error on PrestaShop 9.x
This guide helps to resolve an issue with the PrestaShop v9.x CMS regarding the generation of PDF invoices from the administration panel (Back Office), particularly when the French language is used.
The problem
When attempting to view or download a PDF invoice for an order in French, PrestaShop (version 9.x) returns a 500 Error. This malfunction is due to an incompatibility between the PDF generation library (TCPDF) using the default font (helvetica) and the hosting configurations.
Proposed solution: define a compatible font
The solution is to force the use of the freesans font, which is more compatible, via a custom configuration file.
It is strongly recommended to create a file named defines_custom.inc.php. This method is the safest as it ensures that the correction will not be lost during PrestaShop core updates.
To do this:
- Access your PrestaShop 9.x installation via FTP or the File Manager.
- Navigate to the
/config/directory. - Create a new file named
defines_custom.inc.php. Edit the file
defines_custom.inc.phpand add the following content:<?php /** * Eviter erreur PDF, forcer 'freesans'. */ define('PDF_FONT_NAME_MAIN', 'freesans');- Save the file and test the generation of a French invoice.