How to solving invoice PDF Chinese characters support problem in Magento 2

Magento 2 has some problems with PDF when the language uses Chinese, Arabic, Japanese and some other languages:

When printing an invoice, it will appear the character error as shown below.

Today I will show you how we can fix this error when printing sales invoices.

1.How to change a font in Magento 2 invoice PDF

First overwrite a method of the summary file of the Magento 2 invoice PDF:

Step 1: Create font you need to show, here I need to change font Chinese. I add file Fireflysung.ttf follow the path: lib/internal/GnuFreeFont/Fireflysung.ttf

Magento 2 is using the Zend PDF library. This library can handle only True Type Fonts (.tff) with table version 3. Table version 4 isn’t supported. So your font file has to meet these requirements and support your language characters.

Step 2: Overwrite the file

Create register.php in app\code\Vendor\Module\and add the following code:


Create module.xml in app\code\Vendor\Module\etc and add the following code:

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magepow_CustomPdfFont" schema_version="2.0.0" setup_version="2.0.0">
            <module name="Magento_Sales"/>

Create di.xml which is located at app\code\Vendor\Module\etc and add the following code:

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<preference for="Magento\Sales\Model\Order\Pdf\Invoice" type="Magepow\CustomPdfFont\Model\Order\Pdf\Invoice" />

Create Invoice.php in app\code\Vendor\Module\Model\Order\Pdf and add the following code:

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

namespace Magepow\CustomPdfFont\Model\Order\Pdf;

class Invoice extends \Magento\Sales\Model\Order\Pdf\Invoice

     * Set font as regular
     * @param  \Zend_Pdf_Page $object
     * @param  int $size
     * @return \Zend_Pdf_Resource_Font
    protected function _setFontRegular($object, $size = 7)
        $font = \Zend_Pdf_Font::fontWithPath(
        $object->setFont($font, $size);
        return $font;


If all steps are completed, run standard Magento 2 commands to install a new extension:

php bin/magento setup:upgrade;
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

When you implement the above method, you can set the custom font in the Invoice pdf. Similarly, you can design custom Invoice pdf too!

You can send Invoices that serve as the marketing tool as shown here using the above method:

Hope this article will help you in some way, You can see useful articles in the next articles.

Anything you need support from Magento 2 feels free to contact us at Magepow and

Phone: (+84)865633728