Letters are replaced with question marks or other broken symbols in the PDF. How do I fix it?

Letters are replaced with question marks or other broken symbols in the PDF. How do I fix it?

The issue is rooting in the external dompdf library our extension is using to convert HTML code into PDF. Sometimes it fails to recognize specific fonts or locales. There are 2 alternative ways to fix this:


1. Switch to mPDF library. Starting from v.1.6.0 of the module, we added support for an additional library that handles non-Latin characters in a better way, the feature is available as a part of an active Product Subscription or Support Subscription. To use it, install a suggested composer package by running the following command:

composer require amasty/module-pdf-custom-subscription-functionality

Once done, navigate to admin area at Amasty > PDF Customizer > Configuration > General and make sure that Enabled option is set to Yes. In the Library for PDF Customization drop-down, select mPDF and save the changes:


2. Add external font to the PDF template while using dompdf library. For some languages, it is possible to find online a matching font that will be correctly interpreted by dompdf:

2.1. If you're facing difficulties with the Chinese locale, please navigate to Marketing → PDF Templates → open the template and add the following code in the Template Styles block:

@font-face {
      font-family: font-extra;
      src: url( https://github.com/googlefonts/chinese/blob/gh-pages/fonts/SetoFont/setofont.ttf?raw=true) format('truetype');
      }
      *{ font-family: font-extra !important;}



2.2. In case there's a problem with Arabic characters, please open the template and update the Template Styles block with the code below:

@font-face {
      font-family: El Messiri;
      src: url(https://github.com/Gue3bara/El-Messiri/blob/master/fonts/ttf/ElMessiri-Bold.ttf?raw=true format('truetype');}
      * { font-family: DejaVu Sans, sans-serif; }