Help us understand the problem. What is going on with this article?

mPDFでconfig.phpを触らずに日本語フォントで出力させて文字化けを解消

More than 5 years have passed since last update.

phpからpdfファイルを直接生成させることができる便利なmPDFライブラリだが、そのまま使うと日本語が化けてしまう。

mPDFで日本語フォントで出力するには mpdf/config.php#44

$useAdobeCJK = true; // デフォルトはfalse

と修正する必要があるのだが、composergit submoduleを使ってデプロイされるアプリケーションだと、ライブラリ内にあるconfig.phpを書き換えるのは若干面倒臭い。

そこでmpdfクラスのコンストラクタに下記のように初期化文字列を渡すと、うまいこと解決できる

$mpdf = new mpdf('ja+aCJK');
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away