Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Fix a PDF error on PrestaShop 9.x

This guide helps resolve an issue with the PrestaShop v9.x CMS regarding the generation of PDF invoices from the admin 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.

 

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 fix will not be lost during PrestaShop core updates.

To do this:

  1. Access your PrestaShop 9.x installation via FTP or the File Manager.
  2. Navigate to the /config/ directory.
  3. Create a new file named defines_custom.inc.php.
  4. Edit the file defines_custom.inc.php and add the following content:

    <?php
    /**
     * Eviter erreur PDF, forcer 'freesans'.
     */
    define('PDF_FONT_NAME_MAIN', 'freesans');
  5. Save the file and test the generation of a French invoice.

Has this FAQ been helpful?