How to Fix Japanese and Chinese Character Display Issues in wkhtmltopdf

Tadashi Shigeoka ·  Thu, September 13, 2018

I’ll introduce how to fix the issue where Japanese and Chinese (Simplified and Traditional) characters don’t display in wkhtmltopdf.

wkhtmltopdf

Japanese Support for wkhtmltopdf

Installing Japanese Fonts

Download and extract IPAex Font/IPA Font, then clear the font cache to complete the installation.

mkdir ~/.fonts
cd ~/.fonts
wget http://dl.ipafont.ipa.go.jp/IPAexfont/IPAexfont00301.zip
unzip IPAexfont00301.zip

# Clear font cache
fc-cache -fv

# Check installed fonts list
fc-list | grep IPA

Installing Simplified and Traditional Chinese Fonts

Google’s open source fonts include Chinese fonts Noto Sans CJK SC (Simplified Chinese) and Noto Sans CJK TC (Traditional Chinese), so we’ll use these.

Here’s an example of installing Noto Sans CJK SC (Simplified Chinese):

# Download Noto Sans CJK SC (Simplified Chinese)
mkdir ~/.fonts/NotoSansCJKsc
cd  ~/.fonts/NotoSansCJKsc
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKsc-hinted.zip
unzip NotoSansCJKsc-hinted.zip 

# Clear font cache
fc-cache -fv

# Check installed fonts list
fc-list | grep Noto

That’s all about wanting to use Japanese with wkhtmltopdf from the Gemba.

Reference Information